diff options
author | Florrie <towerofnix@gmail.com> | 2018-08-23 21:39:39 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-08-23 21:39:39 -0300 |
commit | be012d6f2664d52e47d222877eb22f7ab221d02f (patch) | |
tree | c8cbc896620ce3cc4defe1ab9ddd098613c64935 | |
parent | bb8ef46f885fafa97b1d3ab8c2bf890dc9748a8e (diff) |
Misc. tweaks
-rw-r--r-- | img/bbbush1.png | bin | 0 -> 297 bytes | |||
-rw-r--r-- | img/bbbush2.png | bin | 0 -> 268 bytes | |||
-rw-r--r-- | img/bush1.png | bin | 0 -> 681 bytes | |||
-rw-r--r-- | img/bush2.png | bin | 0 -> 763 bytes | |||
-rw-r--r-- | img/bush3.png | bin | 0 -> 665 bytes | |||
-rw-r--r-- | index.js | 31 |
6 files changed, 22 insertions, 9 deletions
diff --git a/img/bbbush1.png b/img/bbbush1.png new file mode 100644 index 0000000..381b958 --- /dev/null +++ b/img/bbbush1.png Binary files differdiff --git a/img/bbbush2.png b/img/bbbush2.png new file mode 100644 index 0000000..d103b23 --- /dev/null +++ b/img/bbbush2.png Binary files differdiff --git a/img/bush1.png b/img/bush1.png new file mode 100644 index 0000000..cb03035 --- /dev/null +++ b/img/bush1.png Binary files differdiff --git a/img/bush2.png b/img/bush2.png new file mode 100644 index 0000000..d4e2f9b --- /dev/null +++ b/img/bush2.png Binary files differdiff --git a/img/bush3.png b/img/bush3.png new file mode 100644 index 0000000..811448b --- /dev/null +++ b/img/bush3.png Binary files differdiff --git a/index.js b/index.js index da94468..30e17cc 100644 --- a/index.js +++ b/index.js @@ -759,7 +759,7 @@ class BattleCharacter extends Sprite { } if (this.targetCharacter) { - this.battle.animationEntities.push(new MagicProjectile(this, this.targetCharacter, action)) + this.battle.miscSprites.push(new MagicProjectile(this, this.targetCharacter, action)) } } @@ -879,7 +879,7 @@ class Battle { this.slideacrossMessage = new SlideacrossMessage() - this.animationEntities = [] + this.miscSprites = [] this.canvas = document.createElement('canvas') @@ -926,8 +926,13 @@ class Battle { } } + const allSprites = [this.backdrop, ...this.getAllBattleCharacters(), ...this.miscSprites] + allSprites.sort((a, b) => { + return a.z < b.z ? 1 : a.z > b.z ? -1 : 0 + }) + const spriteData = [] - for (const sprite of [this.backdrop, ...this.getAllBattleCharacters(), ...this.animationEntities]) { + for (const sprite of allSprites) { sprite.draw() const cameraOffsetX = sprite.x - camera.x @@ -1131,11 +1136,11 @@ class Battle { } } - for (const entity of this.animationEntities) { + for (const entity of this.miscSprites) { entity.update(dt) } - this.animationEntities = this.animationEntities.filter(e => !e.discarded) + this.miscSprites = this.miscSprites.filter(e => !e.discarded) this.slideacrossMessage.update(dt) @@ -1452,11 +1457,11 @@ const basicAI = function() { const battle = new Battle({ teamData: [ {characterData: [ - {x: 0, y: 0, name: 'Ren', hp: 400, maxHP: 400, knownActions: ['fire', 'fira', 'firaga', 'blizz', 'blizzara', 'cure'], determineChain: basicAI}, - {x: -100, y: 0, name: 'Fie', hp: 375, maxHP: 375, knownActions: ['fire', 'blizz', 'blizzara', 'blizzaga', 'aqua', 'aquara', 'curasa'], determineChain: basicAI} + {x: -50, y: 30, name: 'Ren', hp: 400, maxHP: 400, knownActions: ['fire', 'fira', 'firaga', 'blizz', 'blizzara', 'cure'], determineChain: basicAI}, + {x: -75, y: 30, name: 'Fie', hp: 375, maxHP: 375, knownActions: ['fire', 'blizz', 'blizzara', 'blizzaga', 'aqua', 'aquara', 'curasa'], determineChain: basicAI} ]}, {characterData: [ - {x: 0, y: -100, name: 'Manasvin Warmech', hp: 1200, maxHP: 1200, knownActions: ['aqua', 'aquaga', 'manasvinSwipe', 'manasvinRecover'], determineChain: basicAI, knockbackMultiplier: 0} + {x: 75, y: 40, name: 'Manasvin Warmech', hp: 1200, maxHP: 1200, knownActions: ['aqua', 'aquaga', 'manasvinSwipe', 'manasvinRecover'], determineChain: basicAI, knockbackMultiplier: 0} ]} ] }) @@ -1473,10 +1478,18 @@ camera.x = 0 camera.y = 0 camera.z = 0 +for (let i = 0; i < 5 + 10 * Math.random(); i++) { + const sprite = new Sprite() + sprite.x = (Math.random() - 0.5) * 200 + sprite.z = (Math.random() - 0.5) * 20 + sprite.image.src = `img/bbbush${(i % 2) + 1}.png` + battle.miscSprites.push(sprite) +} + battle.canvas.width = canvas.width battle.canvas.height = canvas.height -battle.backdrop.y = 0 +battle.backdrop.z = 80 let lastTime = Date.now() |