diff --git a/js/format-c2m.js b/js/format-c2m.js index 820ac84..2883907 100644 --- a/js/format-c2m.js +++ b/js/format-c2m.js @@ -203,7 +203,7 @@ const TILE_ENCODING = { 0x8a: 'thief_keys', // 0x8b: Ghost : '#direction', '#next' // 0x8c: Steel foil : '#next' - 0x8d: ['turtle', 'water'], + 0x8d: 'turtle', // 0x8e: Secret eye : '#next' // 0x8f: Thief bribe : '#next' // 0x90: Speed boots : '#next' diff --git a/js/main.js b/js/main.js index b3a1c49..d641b2e 100644 --- a/js/main.js +++ b/js/main.js @@ -544,7 +544,8 @@ class Level { if (goal_x >= 0 && goal_x < this.width && goal_y >= 0 && goal_y < this.height) { // Check for a thin wall in our current cell first for (let tile of original_cell) { - if (tile !== actor && tile.type.thin_walls && + if (tile !== actor && + ! tile.type.is_swivel && tile.type.thin_walls && tile.type.thin_walls.has(direction)) { blocked = true; diff --git a/js/tileset.js b/js/tileset.js index e77d582..2f4a9d4 100644 --- a/js/tileset.js +++ b/js/tileset.js @@ -189,7 +189,11 @@ export const CC2_TILESET_LAYOUT = { west: [[9, 12], [10, 12], [11, 12]], }, foil: [12, 12], - turtle: [13, 12], // TODO also 14 + 15 for sinking + turtle: { + // Turtles draw atop fake water, but don't act like water otherwise + overlay: [13, 12], // TODO also 14 + 15 for sinking + base: 'water', + }, walker: [0, 13], // TODO walker animations span multiple tiles, rgh diff --git a/js/tiletypes.js b/js/tiletypes.js index c374850..31183a1 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -88,18 +88,54 @@ const TILE_TYPES = { swivel_ne: { draw_layer: LAYER_OVERLAY, thin_walls: new Set(['north', 'east']), + is_swivel: true, + on_depart(me, level, other) { + if (other.direction === 'north') { + level.transmute_tile(me, 'swivel_se'); + } + else if (other.direction === 'east') { + level.transmute_tile(me, 'swivel_nw'); + } + }, }, swivel_se: { draw_layer: LAYER_OVERLAY, thin_walls: new Set(['south', 'east']), + is_swivel: true, + on_depart(me, level, other) { + if (other.direction === 'south') { + level.transmute_tile(me, 'swivel_ne'); + } + else if (other.direction === 'east') { + level.transmute_tile(me, 'swivel_sw'); + } + }, }, swivel_sw: { draw_layer: LAYER_OVERLAY, thin_walls: new Set(['south', 'west']), + is_swivel: true, + on_depart(me, level, other) { + if (other.direction === 'south') { + level.transmute_tile(me, 'swivel_nw'); + } + else if (other.direction === 'west') { + level.transmute_tile(me, 'swivel_se'); + } + }, }, swivel_nw: { draw_layer: LAYER_OVERLAY, thin_walls: new Set(['north', 'west']), + is_swivel: true, + on_depart(me, level, other) { + if (other.direction === 'north') { + level.transmute_tile(me, 'swivel_ne'); + } + else if (other.direction === 'west') { + level.transmute_tile(me, 'swivel_ne'); + } + }, }, // Locked doors @@ -186,8 +222,11 @@ const TILE_TYPES = { }, }, turtle: { - // XXX well not really because it goes on top of water?? draw_layer: LAYER_TERRAIN, + on_depart(me, level, other) { + // TODO become a splash (good test: push a block on a turtle, then push again; you don't fall in water because the splash blocks you!) + level.transmute_tile(me, 'water'); + }, }, ice: { draw_layer: LAYER_TERRAIN,