code cleanup

This commit is contained in:
2024-08-25 18:45:38 +02:00
parent a470593ae4
commit 8c3f7c2964
4 changed files with 26 additions and 23 deletions

View File

@@ -17,7 +17,7 @@ public class Level {
private int chunkResY;
public Level(Main main, int sizeX, int sizeY) {
GD.Print($"Generating level ({sizeX}:{sizeY})");
GD.Print($"Generating level ({sizeX}:{sizeY}) with {chunksX*chunksY} chunks ({chunkResX} * {chunkResY})");
Resolution = new Vector2I(sizeX, sizeY);
chunksX = main.ChunksPerAxis;
@@ -26,15 +26,14 @@ public class Level {
chunkResX = sizeX / chunksX;
chunkResY = sizeY / chunksY;
GD.Print($"{chunksX}x{chunksY} chunks. {chunkResX}:{chunkResY} res each.");
image = Image.Create(sizeX, sizeY, false, Image.Format.Rgb8);
chunks = new Chunk[chunksX, chunksY];
int index = 0;
// create all chunks
for (int x = 0; x < chunksX; x++) {
for (int y = 0; y < chunksY; y++) {
chunks[x, y] = new Chunk(chunkResX, chunkResY);
chunks[x, y] = new Chunk(chunkResX, chunkResY, index++);
}
}
@@ -47,7 +46,6 @@ public class Level {
if (x > 0) chunks[x, y].NeighborE = chunks[x-1, y];
if (x < chunksX-1) chunks[x, y].NeighborW = chunks[x+1, y];
}
}
}