« get me outta code hell

Make ATB progress more animated - 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-09 20:04:53 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-09 20:04:53 -0300
commit0d600998bd6ad07702491ec91e34e9eedbc7f499 (patch)
treefe2c60152da3a79dffcc352b20644b3788067fbd
parent49b6b42165c313955f39d15e4bc37d6ffed6d102 (diff)
Make ATB progress more animated
-rw-r--r--index.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/index.js b/index.js
index c3f6e6c..cc1f4e4 100644
--- a/index.js
+++ b/index.js
@@ -11,6 +11,7 @@ class ATBBar {
     // State
 
     this.progress = 0
+    this.visualProgress = 0
     this.segmentCount = 6
     this.queuedActions = []
 
@@ -27,7 +28,7 @@ class ATBBar {
     ctx.save()
 
     ctx.beginPath()
-    ctx.rect(0, 0, Math.round(this.canvas.width * this.progress), this.canvas.height)
+    ctx.rect(0, 0, Math.round(this.canvas.width * this.visualProgress), this.canvas.height)
     ctx.clip()
 
     ctx.fillStyle = '#77F'
@@ -79,6 +80,9 @@ class ATBBar {
       this.progress = Math.min(1, this.progress + dt / this.segmentCount)
     }
 
+    // ATB gauge visual update
+    this.visualProgress += 8 * dt * (this.progress - this.visualProgress)
+
     // Action chaining
     if (this.battleCharacter.isExecutingChain && !this.battleCharacter.isExecutingAction) {
       if (this.queuedActions.length) {