added benchmark function
added .txt for benchmark results fixed generating level message
This commit is contained in:
@@ -22,8 +22,6 @@ public class Level {
|
||||
private float rainAmount = 0;
|
||||
|
||||
public Level(Main main, int sizeX, int sizeY) {
|
||||
GD.Print($"Generating level ({sizeX}:{sizeY}) with {chunksX*chunksY} chunks ({chunkResX} * {chunkResY})");
|
||||
|
||||
Resolution = new Vector2I(sizeX, sizeY);
|
||||
chunksX = main.ChunksPerAxis;
|
||||
chunksY = main.ChunksPerAxis;
|
||||
@@ -31,6 +29,8 @@ public class Level {
|
||||
chunkResX = sizeX / chunksX;
|
||||
chunkResY = sizeY / chunksY;
|
||||
|
||||
GD.Print($"Generating level ({sizeX}:{sizeY}) with {chunksX*chunksY} chunks ({chunkResX} * {chunkResY})");
|
||||
|
||||
image = Image.Create(sizeX, sizeY, false, Image.Format.Rgb8);
|
||||
|
||||
chunks = new Chunk[chunksX, chunksY];
|
||||
@@ -66,6 +66,15 @@ public class Level {
|
||||
rainAmount = amount;
|
||||
}
|
||||
|
||||
public void StartBenchmark() {
|
||||
GD.Print("benchmark");
|
||||
for (int x = 0; x < chunksX; x++) {
|
||||
for (int y = 0; y < chunksY; y++) {
|
||||
chunks[x, y].WritePixel<Dirt>(chunkResX/2, chunkResY/2, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MakeItRain() {
|
||||
if (rainAmount < .1f) return;
|
||||
|
||||
@@ -87,6 +96,7 @@ public class Level {
|
||||
|
||||
for (int x = 0; x < chunkResX; x++) {
|
||||
for (int y = 0; y < chunkResY; y++) {
|
||||
// TODO: multithreading here! use Chunk.DrawLevel() and stitch images together
|
||||
image.SetPixel(cx*chunkResX + x, cy*chunkResY + y, chunks[cx,cy].Elements[x, y].Color);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user