From 16f87bf6e07738687ee0b19b82c9c5a6770e4761 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Sat, 19 Sep 2020 22:47:04 -0600 Subject: [PATCH] Fix hot blocks appearing to move backwards on death --- js/game.js | 11 +++++++++-- js/renderer-canvas.js | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/js/game.js b/js/game.js index c2389ae..99eb151 100644 --- a/js/game.js +++ b/js/game.js @@ -356,7 +356,11 @@ export class Level { // Used to check for a monster chomping the player's tail this.player_leaving_cell = this.player.cell; - // First pass: tick cooldowns and animations; have actors arrive in their cells + // First pass: tick cooldowns and animations; have actors arrive in their cells. We do the + // arrival as its own mini pass, for one reason: if the player dies (which will end the game + // immediately), we still want every time's animation to finish, or it'll look like some + // objects move backwards when the death screen appears! + let cell_steppers = []; for (let actor of this.actors) { // Actors with no cell were destroyed if (! actor.cell) @@ -381,11 +385,14 @@ export class Level { this._set_prop(actor, 'animation_progress', null); this._set_prop(actor, 'animation_speed', null); if (! this.compat.tiles_react_instantly) { - this.step_on_cell(actor); + cell_steppers.push(actor); } } } } + for (let actor of cell_steppers) { + this.step_on_cell(actor); + } // Second pass: actors decide their upcoming movement simultaneously for (let actor of this.actors) { diff --git a/js/renderer-canvas.js b/js/renderer-canvas.js index cc95679..575bda3 100644 --- a/js/renderer-canvas.js +++ b/js/renderer-canvas.js @@ -58,7 +58,6 @@ export class CanvasRenderer { return; } - // TODO StoredLevel may not have a tic_counter let tic = (this.level.tic_counter ?? 0) + tic_offset; let tw = this.tileset.size_x; let th = this.tileset.size_y;