From 4c9bc240f9e5fe1a16029107132d2accb16ef5d4 Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 9 Aug 2018 21:13:23 -0300 Subject: Sprite position tweaks, fix issue w/ asset loading --- index.js | 13 ++++++++----- 1 file 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() -- cgit 1.3.0-6-gf8a5