« 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.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/index.js b/index.js
index ad0f71a..d9796ed 100644
--- a/index.js
+++ b/index.js
@@ -1031,8 +1031,8 @@ class Battle {
     for (const { x, y, battleCharacter } of overlayHPBars) {
       const hpBar = battleCharacter.hpBar
       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))
+      const drawX = Math.min(this.canvas.width - 10 - hpBar.canvas.width, Math.max(10 + hpBar.labelCanvas.width, Math.round(x - hpBar.canvas.width / 2)))
+      const drawY = Math.min(this.canvas.height - 20, 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)
     }