From 8428572def74d82db6a20118dbe2071a41c2d7c1 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Sun, 6 Dec 2020 16:29:07 -0700 Subject: [PATCH] Step in reverse order; allow pushing blocks on railroads; gliders ignore turtles --- js/game.js | 20 +++++++++++++------- js/tiletypes.js | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/js/game.js b/js/game.js index cc186a7..17c01d3 100644 --- a/js/game.js +++ b/js/game.js @@ -83,12 +83,17 @@ export class Tile { } can_push(tile, direction) { - return ( - this.type.pushes && this.type.pushes[tile.type.name] && - (! tile.type.allows_push || tile.type.allows_push(tile, direction)) && - // Need to explicitly check this here, otherwise you could /attempt/ to push a block, - // which would fail, but it would still change the block's direction - ! tile.cell.blocks_leaving(tile, direction)); + if (! (this.type.pushes && this.type.pushes[tile.type.name] && + (! tile.type.allows_push || tile.type.allows_push(tile, direction)))) + { + return false; + } + + // Obey railroad curvature + direction = tile.cell.redirect_exit(tile, direction); + // Need to explicitly check this here, otherwise you could /attempt/ to push a block, + // which would fail, but it would still change the block's direction + return ! tile.cell.blocks_leaving(tile, direction); } // Inventory stuff @@ -1012,7 +1017,8 @@ export class Level { // Step on every tile in a cell we just arrived in step_on_cell(actor, cell) { let teleporter; - for (let tile of Array.from(cell)) { + // Step on topmost things first -- notably, it's safe to step on water with flippers on top + for (let tile of Array.from(cell).reverse()) { if (tile === actor) continue; if (actor.ignores(tile.type.name)) diff --git a/js/tiletypes.js b/js/tiletypes.js index 47a2fb5..1099fb2 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -1688,7 +1688,7 @@ const TILE_TYPES = { collision_mask: COLLISION.monster_generic, blocks_collision: COLLISION.all_but_player, movement_speed: 4, - ignores: new Set(['water']), + ignores: new Set(['water', 'turtle']), // doesn't cause turtles to disappear decide_movement(me, level) { // turn left: preserve current direction; if that doesn't work, turn left, then right, // then back the way we came