« get me outta code hell

csb-game - Pixelly spin-off of the Command Synergy Battle system used in Final Fantasy XIII
summary refs log tree commit diff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/index.js b/index.js
index 237a9e3..79d7d7f 100644
--- a/index.js
+++ b/index.js
@@ -941,7 +941,7 @@ class Battle {
 
         ctx.font = '5px pixel-font'
         const width = ctx.measureText(label).width + 4
-        const x = Math.round(sprite.x - sprite.canvas.width / 2 - width / 2)
+        const x = Math.round(sprite.x - width / 2)
         const y = Math.round(sprite.y - sprite.canvas.height / 2)
 
         let textFillStyle
@@ -1030,9 +1030,9 @@ class Battle {
 
     for (const { x, y, battleCharacter } of overlayHPBars) {
       const hpBar = battleCharacter.hpBar
-      const drawX = Math.round(x - hpBar.canvas.width / 2)
-      const drawY = Math.round(y - hpBar.canvas.height)
       hpBar.draw()
+      const drawX = Math.max(10 + hpBar.labelCanvas.width, Math.round(x - hpBar.canvas.width / 2))
+      const drawY = Math.max(10, Math.round(y - hpBar.canvas.height))
       ctx.drawImage(hpBar.canvas, drawX, drawY)
       ctx.drawImage(hpBar.labelCanvas, drawX - hpBar.labelCanvas.width - 2, drawY - 1)
     }