Step in reverse order; allow pushing blocks on railroads; gliders ignore turtles

This commit is contained in:
Eevee (Evelyn Woods) 2020-12-06 16:29:07 -07:00
parent 4838bb189b
commit 8428572def
2 changed files with 14 additions and 8 deletions

View File

@ -83,12 +83,17 @@ export class Tile {
} }
can_push(tile, direction) { can_push(tile, direction) {
return ( if (! (this.type.pushes && this.type.pushes[tile.type.name] &&
this.type.pushes && this.type.pushes[tile.type.name] && (! tile.type.allows_push || tile.type.allows_push(tile, direction))))
(! 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, // 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 // which would fail, but it would still change the block's direction
! tile.cell.blocks_leaving(tile, direction)); return ! tile.cell.blocks_leaving(tile, direction);
} }
// Inventory stuff // Inventory stuff
@ -1012,7 +1017,8 @@ export class Level {
// Step on every tile in a cell we just arrived in // Step on every tile in a cell we just arrived in
step_on_cell(actor, cell) { step_on_cell(actor, cell) {
let teleporter; 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) if (tile === actor)
continue; continue;
if (actor.ignores(tile.type.name)) if (actor.ignores(tile.type.name))

View File

@ -1688,7 +1688,7 @@ const TILE_TYPES = {
collision_mask: COLLISION.monster_generic, collision_mask: COLLISION.monster_generic,
blocks_collision: COLLISION.all_but_player, blocks_collision: COLLISION.all_but_player,
movement_speed: 4, movement_speed: 4,
ignores: new Set(['water']), ignores: new Set(['water', 'turtle']), // doesn't cause turtles to disappear
decide_movement(me, level) { decide_movement(me, level) {
// turn left: preserve current direction; if that doesn't work, turn left, then right, // turn left: preserve current direction; if that doesn't work, turn left, then right,
// then back the way we came // then back the way we came