From 5ef436498f70b0b87926cb975422b9674d39869c Mon Sep 17 00:00:00 2001 From: "Kacper Kostka (aider)" Date: Fri, 4 Apr 2025 11:55:14 +0200 Subject: [PATCH] feat: Move default player position to Chunk: 0,-1 and adjust floor to bottom edge --- script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index 6c08d9a..cbe7394 100644 --- a/script.js +++ b/script.js @@ -46,7 +46,7 @@ let currentMouseX, currentMouseY; let lastFrameTime = 0; let fps = 0; let worldOffsetX = 0; -let worldOffsetY = 0; +let worldOffsetY = CHUNK_SIZE; // Start at Chunk: 0,-1 let worldOffsetXBeforeDrag = 0; let worldOffsetYBeforeDrag = 0; let chunks = new Map(); // Map to store chunks with key "x,y" @@ -311,7 +311,7 @@ function getOrCreateChunk(chunkX, chunkY) { if (chunkY === 0) { // Fill the bottom row with walls for (let x = 0; x < CHUNK_SIZE; x++) { - chunkData[0 * CHUNK_SIZE + x] = WALL; + chunkData[(CHUNK_SIZE - 1) * CHUNK_SIZE + x] = WALL; } } @@ -340,7 +340,7 @@ function setPixel(worldX, worldY, type) { function getPixel(worldX, worldY) { // Special case: floor at the bottom of the world - if (worldY === 0) { + if (worldY === CHUNK_SIZE - 1 && Math.floor(worldY / CHUNK_SIZE) === 0) { return WALL; }