fixed chunk neighbor orientation

This commit is contained in:
2024-07-14 18:15:14 +02:00
parent 3f02d4036a
commit 29185791d9
2 changed files with 21 additions and 15 deletions

View File

@@ -26,6 +26,8 @@ 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];
@@ -40,11 +42,12 @@ public class Level {
for (int x = 0; x < chunksX; x++) {
for (int y = 0; y < chunksY; y++) {
if (x > 0) chunks[x, y].NeighborN = chunks[x-1, y];
if (x < chunksX-1) chunks[x, y].NeighborS = chunks[x+1, y];
if (y > 0) chunks[x, y].NeighborN = chunks[x, y-1];
if (y < chunksY-1) chunks[x, y].NeighborS = chunks[x, y+1];
if (x > 0) chunks[x, y].NeighborE = chunks[x-1, y];
if (x < chunksX-1) chunks[x, y].NeighborW = chunks[x+1, y];
if (y > 0) chunks[x, y].NeighborW = chunks[x, y-1];
if (y < chunksY-1) chunks[x, y].NeighborE = chunks[x, y+1];
}
}
}