« get me outta code hell

Camera tweaks - csb-game - Pixelly spin-off of the Command Synergy Battle system used in Final Fantasy XIII
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-08-20 11:09:02 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-20 11:09:02 -0300
commit8f331f13feeff576c36b1c0afd398a261ee3fb43 (patch)
treea54e8aa0ea5ff056db9a1256edf94bc4b5124752
parent9922a898f806e53faa63a5d82d0f498e74f55de3 (diff)
Camera tweaks
-rw-r--r--index.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/index.js b/index.js
index 79d7d7f..ad0f71a 100644
--- a/index.js
+++ b/index.js
@@ -1270,13 +1270,17 @@ class BattleCamera extends Camera {
 
     const characters = this.battle.getAllBattleCharacters()
 
-    const leftmostX = characters.reduce((acc, c) => Math.min(acc, c.x), 0)
-    const rightmostX = characters.reduce((acc, c) => Math.max(acc, c.x), 0)
-    const distanceX = Math.abs(leftmostX - rightmostX)
+    const leftmostX = characters.reduce((acc, c) => Math.min(acc, c.x), characters[0].x)
+    const rightmostX = characters.reduce((acc, c) => Math.max(acc, c.x), characters[0].x)
+    // const distanceX = Math.abs(leftmostX - rightmostX)
+
+    const topmostY = characters.reduce((acc, c) => Math.min(acc, c.y), characters[0].y)
+    const bottommostY = characters.reduce((acc, c) => Math.max(acc, c.y), characters[0].y)
+    // const distanceY = Math.abs(topmostY - bottommostY)
 
     return {
       x: (leftmostX + rightmostX) / 2,
-      y: by
+      y: (topmostY + bottommostY) / 2
     }
   }
 }