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();