Fix missing trees at game start by generating them after npcWorldX is set
This commit is contained in:
1 parent
446d56bf38
commit
ddf0a9cb08
1 file changed
+2
-4
@@ -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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user