diff options
-rw-r--r-- | index.js | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/index.js b/index.js index cc1f4e4..137fd44 100644 --- a/index.js +++ b/index.js @@ -289,7 +289,7 @@ class BattleCharacter { const battleCharacter = new BattleCharacter() const atbBar = battleCharacter.atbBar -atbBar.queuedActions = [{label: 'Fire', size: 1}, {label: 'Blizz', size: 1}, {label: 'Zap', size: 1}, {label: 'Firaga', size: 3}] +//atbBar.queuedActions = [{label: 'Fire', size: 1}, {label: 'Blizz', size: 1}, {label: 'Zap', size: 1}, {label: 'Firaga', size: 3}] const actionMenu = new ActionMenu() @@ -300,35 +300,44 @@ function drawLoop() { lastTime = Date.now() battleCharacter.update(dt) - atbBar.draw() - - actionMenu.draw() const ctx = canvas.getContext('2d') ctx.clearRect(0, 0, canvas.width, canvas.height) ctx.fillStyle = '#EEE' ctx.fillRect(0, 0, canvas.width, canvas.height) - ctx.drawImage(actionMenu.canvas, 20, canvas.height - 20 - actionMenu.canvas.height) - ctx.drawImage(atbBar.canvas, 20, canvas.height - 20 - actionMenu.canvas.height - 2 - atbBar.canvas.height) + + let y = canvas.height - 20 + if (!battleCharacter.isExecutingChain) { + y -= actionMenu.canvas.height + actionMenu.draw() + ctx.drawImage(actionMenu.canvas, 20, y) + y -= 2 + } + atbBar.draw() + ctx.drawImage(atbBar.canvas, 20, y - atbBar.canvas.height) requestAnimationFrame(drawLoop) } canvas.addEventListener('keypress', evt => { - if (evt.keyCode === 38) { - actionMenu.upOption() - } else if (evt.keyCode === 40) { - actionMenu.downOption() - } else if (evt.keyCode === 37) { - actionMenu.decreaseLevel() - } else if (evt.keyCode === 39) { - actionMenu.increaseLevel() - } else if (evt.which === 32) { - actionMenu.queueTo(atbBar) - } else if (evt.keyCode === 8) { - atbBar.dequeue() - } else if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e') { - atbBar.activate() + if (!battleCharacter.isExecutingChain) { + if (evt.keyCode === 38) { + actionMenu.upOption() + } else if (evt.keyCode === 40) { + actionMenu.downOption() + } else if (evt.keyCode === 37) { + actionMenu.decreaseLevel() + } else if (evt.keyCode === 39) { + actionMenu.increaseLevel() + } else if (evt.which === 32) { + actionMenu.queueTo(atbBar) + } else if (evt.keyCode === 8) { + atbBar.dequeue() + } else if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e') { + atbBar.activate() + } + } else { + // TODO: Backspace to cancel chain } }) |