diff --git a/game.js b/game.js index 59536c6..4a6d419 100644 --- a/game.js +++ b/game.js @@ -385,11 +385,12 @@ class Game { /* Player sprite stays horizontally centred; only Y shifts */ const p = document.getElementById('map-player'); - if (p) { + const pw = document.getElementById('map-player-wrap'); + if (p && pw) { const centreX = viewW / 2 - 16; const centreY = viewH * 0.65 + this.state.worldY; - p.style.left = centreX + 'px'; - p.style.bottom = (viewH - centreY - 40) + 'px'; + pw.style.left = centreX + 'px'; + pw.style.bottom = (viewH - centreY - 40) + 'px'; p.className = `map-player walk-${dir}`; } @@ -454,11 +455,20 @@ class Game { _talkToNPC() { if (!this._nearNPC()) { - this.toast('Walk up to the NPC first!'); + const bub = document.getElementById('player-bubble'); + if (bub) { + bub.classList.remove('visible'); + void bub.offsetWidth; + bub.classList.add('visible'); + clearTimeout(this._bubbleTimer); + this._bubbleTimer = setTimeout(() => bub.classList.remove('visible'), 1500); + } return; } const arrow = document.getElementById('map-dir-arrow'); if (arrow) arrow.style.display = 'none'; + const bub = document.getElementById('player-bubble'); + if (bub) bub.classList.remove('visible'); SFX.encounter(); this.startQuestion(); } @@ -470,11 +480,11 @@ class Game { const viewH = world ? world.parentElement.offsetHeight : 300; const p = document.getElementById('map-player'); - if (p) { - p.style.left = (viewW / 2 - 16) + 'px'; - p.style.bottom = (viewH * 0.28) + 'px'; - - p.className = 'map-player idle'; + const pw = document.getElementById('map-player-wrap'); + if (p && pw) { + pw.style.left = (viewW / 2 - 16) + 'px'; + pw.style.bottom = (viewH * 0.28) + 'px'; + p.className = 'map-player idle'; } this._applyCamera(); const hint = document.getElementById('map-talk-hint'); diff --git a/index.html b/index.html index 42f7adc..a052f6f 100644 --- a/index.html +++ b/index.html @@ -109,7 +109,10 @@
- +