From ddf0a9cb0808c1b3578a4b3b196fc6bad66005d5 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Wed, 20 May 2026 21:02:42 -0700 Subject: [PATCH] Fix missing trees at game start by generating them after npcWorldX is set --- game.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/game.js b/game.js index aa97e1f..ffb2167 100644 --- a/game.js +++ b/game.js @@ -1036,9 +1036,7 @@ class Game { this.show('map'); this._showController(true); - /* We need the viewport size — defer a tick so the DOM is laid out */ requestAnimationFrame(() => { - this._generateTrees(); const world = document.getElementById('map-inner'); const viewW = world ? world.parentElement.offsetWidth : 420; @@ -1048,14 +1046,14 @@ class Game { this.state.npcWorldX = Math.round(viewW * 3.5); this.state.npcWorldY = 0; } else { - /* Always reset camera to 0 each question — keeps trees in view. - NPC spawns off-screen right relative to fresh origin. */ this.state.worldX = 0; this.state.worldY = 0; this.state.npcWorldX = Math.round(viewW * 3.0 + Math.random() * viewW * 0.8); this.state.npcWorldY = 0; } + this._generateTrees(); + document.getElementById('hud-name').textContent = this.state.playerName||'ASH'; this.updateHUD();