« get me outta code hell

Sprite position tweaks, fix issue w/ asset loading - 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 21:13:23 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-09 21:13:23 -0300
commit4c9bc240f9e5fe1a16029107132d2accb16ef5d4 (patch)
tree319f2542f4e448079db891fc8be793ff80f20ff0
parentfa469092ab153abcb3152b54368927e3f7a772e4 (diff)
Sprite position tweaks, fix issue w/ asset loading
-rw-r--r--index.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/index.js b/index.js
index 24cccbe..e7653d8 100644
--- a/index.js
+++ b/index.js
@@ -13,10 +13,12 @@ class Sprite {
   update(dt) {}
 
   draw() {
-    this.canvas.width = this.image.width
-    this.canvas.height = this.image.height
-    const ctx = this.canvas.getContext('2d')
-    ctx.drawImage(this.image, 0, 0)
+    if (this.image.complete) {
+      this.canvas.width = this.image.width
+      this.canvas.height = this.image.height
+      const ctx = this.canvas.getContext('2d')
+      ctx.drawImage(this.image, 0, 0)
+    }
   }
 }
 
@@ -336,7 +338,7 @@ class Camera extends Sprite {
 }
 
 const battleCharacter = new BattleCharacter()
-battleCharacter.x = 80
+battleCharacter.x = 0
 battleCharacter.y = 80
 
 const atbBar = battleCharacter.atbBar
@@ -350,6 +352,7 @@ camera.height = canvas.height
 camera.follow(battleCharacter)
 
 const backdrop = new Backdrop()
+backdrop.y = 300 / 2
 
 let lastTime = Date.now()