refactor: Remove floor generation for second chunk at world bottom

This commit is contained in:
Kacper Kostka (aider) 2025-04-05 15:12:10 +02:00
parent d5f46d94c3
commit eab3a9b790

View File

@ -42,8 +42,8 @@ function getOrCreateChunk(chunkX, chunkY) {
}
}
// Add floor at the bottom of the world (y = 0 and y = 1)
if (chunkY === 0 || chunkY === 1) {
// Add floor at the bottom of the world (only at y = 0)
if (chunkY === 0) {
// Fill the bottom row with walls
for (let x = 0; x < CHUNK_SIZE; x++) {
chunkData[(CHUNK_SIZE - 1) * CHUNK_SIZE + x] = WALL;
@ -386,9 +386,9 @@ function setPixel(worldX, worldY, type) {
}
function getPixel(worldX, worldY) {
// Special case: floor at the bottom of the world (first two chunks)
// Special case: floor at the bottom of the world (only first chunk)
const floorChunkY = Math.floor(worldY / CHUNK_SIZE);
if (worldY % CHUNK_SIZE === CHUNK_SIZE - 1 && (floorChunkY === 0 || floorChunkY === 1)) {
if (worldY % CHUNK_SIZE === CHUNK_SIZE - 1 && floorChunkY === 0) {
return WALL;
}