refactor: Remove floor generation and related code from world generation
This commit is contained in:
parent
7aa0c1785b
commit
908c819441
16
js/world.js
16
js/world.js
@ -42,13 +42,7 @@ function getOrCreateChunk(chunkX, chunkY) {
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
// Floor has been removed as it's no longer needed
|
||||
|
||||
// Get the current player chunk position
|
||||
const playerChunkX = Math.floor(worldOffsetX / CHUNK_SIZE);
|
||||
@ -386,12 +380,6 @@ function setPixel(worldX, worldY, type) {
|
||||
}
|
||||
|
||||
function getPixel(worldX, worldY) {
|
||||
// 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) {
|
||||
return WALL;
|
||||
}
|
||||
|
||||
const { chunkX, chunkY, localX, localY } = getChunkCoordinates(worldX, worldY);
|
||||
const key = getChunkKey(chunkX, chunkY);
|
||||
|
||||
@ -453,7 +441,7 @@ function generateChunksAroundPlayer() {
|
||||
const centerChunkY = Math.floor(worldOffsetY / CHUNK_SIZE);
|
||||
const radius = 3; // Generate chunks within 3 chunks of the player
|
||||
|
||||
// Always generate the stone layer at y = 1 instead of below the floor
|
||||
// Always generate the stone layer at y = 1
|
||||
for (let dx = -radius; dx <= radius; dx++) {
|
||||
const chunkX = centerChunkX + dx;
|
||||
const chunkY = 1; // The chunk at y = 1 (moved from y = -1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user