From d3dfcba63b7a797cf58bd67f157c6fb6d05b7fbb Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Sat, 12 Sep 2020 20:45:34 -0600 Subject: [PATCH] Don't remove the player when stepping on a bomb; it breaks things --- js/game.js | 10 +++++++++- js/main.js | 2 ++ js/tiletypes.js | 11 ++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/js/game.js b/js/game.js index 1767559..831da5f 100644 --- a/js/game.js +++ b/js/game.js @@ -946,7 +946,15 @@ export class Level { let current = tile.type.name; this.pending_undo.push(() => tile.type = TILE_TYPES[current]); tile.type = TILE_TYPES[name]; - // TODO adjust anything else? + + // For transmuting into an animation, set up the timer immediately + if (tile.type.ttl) { + if (! TILE_TYPES[current].is_actor) { + console.warn("Transmuting a non-actor into an animation!"); + } + this._set_prop(tile, 'animation_speed', tile.type.ttl); + this._set_prop(tile, 'animation_progress', 0); + } } give_actor(actor, name) { diff --git a/js/main.js b/js/main.js index 7c20ec7..3daa734 100644 --- a/js/main.js +++ b/js/main.js @@ -490,6 +490,8 @@ class Player extends PrimaryView { // Redraws every frame, unless the game isn't running redraw() { + // FIXME draw one more frame after losing, so we can see the player explode or whatever + // TODO for bonus points, also finish the player animation (but don't advance the game any further) if (this.state !== 'playing' && this.state !== 'rewinding') { this._redraw_handle = null; return; diff --git a/js/tiletypes.js b/js/tiletypes.js index e2142ad..8d29dc5 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -291,15 +291,15 @@ const TILE_TYPES = { level.transmute_tile(other, 'player_drowned'); } else { - level.remove_tile(other); + level.transmute_tile(other, 'splash'); } - level.spawn_animation(me.cell, 'splash'); }, }, turtle: { draw_layer: LAYER_TERRAIN, on_depart(me, level, other) { level.transmute_tile(me, 'water'); + // TODO feels like we should spawn water underneath us, then transmute ourselves into the splash? level.spawn_animation(me.cell, 'splash'); }, }, @@ -411,11 +411,11 @@ const TILE_TYPES = { on_arrive(me, level, other) { let cell = me.cell; level.remove_tile(me); - level.remove_tile(other); - level.spawn_animation(cell, 'explosion'); if (other.type.is_player) { + // Check this /before/ we change it... level.fail("watch where you step"); } + level.transmute_tile(other, 'explosion'); }, }, thief_tools: { @@ -509,10 +509,11 @@ const TILE_TYPES = { on_arrive(me, level, other) { // TODO explode level.remove_tile(me); - level.remove_tile(other); if (other.type.is_player) { + // Check this /before/ we change it... level.fail("watch where you step"); } + level.transmute_tile(other, 'explosion'); }, }, cloner: {