From 325a06395d81ed1fbd829a2df60bf8956f82a9c1 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Mon, 28 Sep 2020 04:09:24 -0600 Subject: [PATCH] Partly implement gray buttons; expose them and green stuff in the editor --- js/main-editor.js | 6 ++++++ js/tiletypes.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/js/main-editor.js b/js/main-editor.js index 402f61e..041db97 100644 --- a/js/main-editor.js +++ b/js/main-editor.js @@ -515,6 +515,12 @@ const EDITOR_PALETTE = [{ 'bomb', 'dirt_block', 'ice_block', + 'button_gray', + 'button_green', + 'green_floor', + 'green_wall', + 'green_chip', + 'green_bomb', 'button_blue', 'button_red', 'cloner', 'button_brown', 'trap', diff --git a/js/tiletypes.js b/js/tiletypes.js index 362f22f..5981bda 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -851,6 +851,34 @@ const TILE_TYPES = { // TODO not implemented draw_layer: LAYER_TERRAIN, }, + button_gray: { + // TODO only partially implemented + draw_layer: LAYER_TERRAIN, + on_arrive(me, level, other) { + level.sfx.play_once('button-press', me.cell); + + for (let x = Math.max(0, me.cell.x - 2); x <= Math.min(level.width - 1, me.cell.x + 2); x++) { + for (let y = Math.max(0, me.cell.y - 2); y <= Math.min(level.height - 1, me.cell.y + 2); y++) { + let cell = level.cells[y][x]; + // TODO wait is this right + if (cell === me.cell) + continue; + + for (let tile of cell) { + if (tile.type.name === 'green_floor') { + tile.type = TILE_TYPES['green_wall']; + } + else if (tile.type.name === 'green_wall') { + tile.type = TILE_TYPES['green_floor']; + } + } + } + } + }, + on_depart(me, level, other) { + level.sfx.play_once('button-release', me.cell); + }, + }, // Time alteration stopwatch_bonus: {