From 67504e436ed2bc19a225340834ccf31242d8c8ef Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Wed, 23 Sep 2020 21:09:57 -0600 Subject: [PATCH] Draw the player's blocked/pushing frame (at last) --- js/game.js | 20 +++++++++++++++++++- js/tileset.js | 2 ++ js/tiletypes.js | 6 ++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/js/game.js b/js/game.js index a1b2402..bcc99df 100644 --- a/js/game.js +++ b/js/game.js @@ -354,6 +354,10 @@ export class Level { // Used to check for a monster chomping the player's tail this.player_leaving_cell = this.player.cell; + // Used for visual effect and updated later; don't need to be undoable + // because they only apply while holding a key down anyway + // TODO but maybe they should be undone anyway so rewind looks better + this.player.is_blocked = false; // 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 @@ -397,6 +401,11 @@ export class Level { this.step_on_cell(actor); } + // Only reset the player's is_pushing between movement, so it lasts for the whole push + if (this.player.movement_cooldown <= 0) { + this.player.is_pushing = false; + } + // Second pass: actors decide their upcoming movement simultaneously for (let actor of this.actors) { if (! actor.cell) @@ -559,7 +568,12 @@ export class Level { continue; let old_cell = actor.cell; - this.attempt_step(actor, actor.decision); + let success = this.attempt_step(actor, actor.decision); + + // Track whether the player is blocked, for visual effect + if (actor === this.player && p1_primary_direction && ! success) { + actor.is_blocked = true; + } // Players can also bump the tiles in the cell next to the one they're leaving let dir2 = actor.secondary_direction; @@ -575,6 +589,7 @@ export class Level { } if (could_push && actor.can_push(tile)) { // Block slapping: you can shove a block by walking past it sideways + // TODO i think cc2 uses the push pose and possibly even turns you here? this.attempt_step(tile, dir2); } } @@ -697,6 +712,9 @@ export class Level { for (let tile of Array.from(goal_cell)) { if (actor.can_push(tile)) { this.attempt_step(tile, direction); + if (actor === this.player) { + actor.is_pushing = true; + } } } diff --git a/js/tileset.js b/js/tileset.js index 0759022..064b505 100644 --- a/js/tileset.js +++ b/js/tileset.js @@ -298,6 +298,7 @@ export const CC2_TILESET_LAYOUT = { west: [8, 23], east: [8, 22], }, + blocked: 'pushing', moving: { north: [[0, 22], [1, 22], [2, 22], [3, 22], [4, 22], [5, 22], [6, 22], [7, 22]], east: [[8, 22], [9, 22], [10, 22], [11, 22], [12, 22], [13, 22], [14, 22], [15, 22]], @@ -532,6 +533,7 @@ export const TILE_WORLD_TILESET_LAYOUT = { }, moving: 'normal', pushing: 'normal', + blocked: 'normal', swimming: { north: [3, 12], west: [3, 13], diff --git a/js/tiletypes.js b/js/tiletypes.js index 3360e29..fa3458a 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -34,6 +34,12 @@ function player_visual_state(me) { else if (me.slide_mode === 'force') { return 'forced'; } + else if (me.is_blocked) { + return 'blocked'; + } + else if (me.is_pushing) { + return 'pushing'; + } else if (me.animation_speed) { return 'moving'; }