From 439451229c06744c5c4b490c7784c30954c5e49a Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Thu, 21 May 2026 11:58:42 -0700 Subject: [PATCH] Replace NPC emoji with sprite: oak.png --- game.js | 22 ++++++++++++++++++---- index.html | 2 +- style.css | 4 ++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/game.js b/game.js index 4f05277..b8d658b 100644 --- a/game.js +++ b/game.js @@ -16,8 +16,22 @@ const CONFIG = { namePrompt: "Hello there! Welcome to PokéAzure! My name is Professor Oak — the Azure Pokémon Professor. Now tell me, what is your name?", }; + +function setNPC(el, val) { + if (!el) return; + if (val && val.endsWith('.png')) { + el.innerHTML = ''; + const img = document.createElement('img'); + img.src = val; + img.style.cssText = 'height:1em;width:auto;image-rendering:pixelated;vertical-align:middle;'; + el.appendChild(img); + } else { + el.textContent = val || '🧑'; + } +} + const NPC = { - 'Professor Oak': '👴', + 'Professor Oak': './oak.png', 'Rival Gary': '😤', 'Old Man Bob': '🧓', 'Nurse Joy': '👩‍⚕️', @@ -998,7 +1012,7 @@ class Game { const msg = INTRO_MSGS[this.state.introStep]; if (!msg) return; const npcEl = document.getElementById('intro-npc'); - if (npcEl) npcEl.textContent = NPC[msg.npc] || '👴'; + if (npcEl) setNPC(npcEl, NPC[msg.npc] || '👴'); document.getElementById('intro-speaker').textContent = msg.speaker; document.getElementById('intro-arrow').style.display = 'none'; this.typeText('intro-text', @@ -1133,7 +1147,7 @@ class Game { const q = this.state.questions[this.state.currentQ]; const npcEl = document.getElementById('map-npc'); - if (q && npcEl) npcEl.textContent = NPC[q.npc]||'🧑'; + if (q && npcEl) setNPC(npcEl, NPC[q.npc]||'🧑'); this._placeMapSprites(); this._checkNPCProximity(); @@ -1181,7 +1195,7 @@ class Game { this.state.answering=false; this.state.cursor=0; - document.getElementById('battle-npc-sprite').textContent = NPC[q.npc]||'🧑'; + setNPC(document.getElementById('battle-npc-sprite'), NPC[q.npc]||'🧑'); document.getElementById('battle-npc-name').textContent = q.npc.toUpperCase(); document.getElementById('battle-speaker').textContent = q.npc.toUpperCase(); document.getElementById('battle-player-name').textContent= (this.state.playerName||'ASH').toUpperCase(); diff --git a/index.html b/index.html index f95c4a4..0f12707 100644 --- a/index.html +++ b/index.html @@ -74,7 +74,7 @@
-
👴
+
diff --git a/style.css b/style.css index 27a1619..e958371 100644 --- a/style.css +++ b/style.css @@ -414,6 +414,8 @@ html, body { #screen-intro { flex-direction:column-reverse; } .intro-dialog { margin:10px; min-height:90px; } .intro-npc { position:absolute; right:22%; bottom:30%; font-size:clamp(44px,13vw,64px); animation:npcFloat 2s ease-in-out infinite; filter:drop-shadow(2px 3px 0 rgba(0,0,0,.4)); } +.intro-npc img { height:clamp(44px,13vw,64px); width:auto; image-rendering:pixelated; display:block; } +.intro-npc img { height:clamp(44px,13vw,64px); width:auto; image-rendering:pixelated; display:block; } .intro-player { position: absolute; left: 22%; @@ -495,6 +497,8 @@ html, body { .map-npc-wrap { position:absolute; text-align:center; z-index: 30; } .npc-bubble { font-size:14px; font-family:var(--font); color:var(--black); background:var(--yellow); border:2px solid var(--black); width:20px; height:20px; display:flex; align-items:center; justify-content:center; margin:0 auto 2px; animation:bounce .7s ease-in-out infinite; } .map-npc { font-size:clamp(36px,10vw,52px); filter:drop-shadow(2px 3px 0 rgba(0,0,0,.35)); cursor:pointer; animation:npcFloat 2s ease-in-out infinite; } +.map-npc img { height:clamp(36px,10vw,52px); width:auto; image-rendering:pixelated; display:block; } +.map-npc img { height:clamp(36px,10vw,52px); width:auto; image-rendering:pixelated; display:block; } /* Player is fixed to the viewport centre horizontally; only Y moves */ /* "..." bubble above player when pressing talk away from NPC */ .player-bubble {