From 30261a106f3eac23be7457b1cf336a7556a7063b Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Sun, 6 Dec 2020 16:51:24 -0700 Subject: [PATCH] Mostly implement rover --- js/tileset.js | 22 ++++++++++++++++++++-- js/tiletypes.js | 26 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/js/tileset.js b/js/tileset.js index 8d99373..ef564f8 100644 --- a/js/tileset.js +++ b/js/tileset.js @@ -344,8 +344,26 @@ export const CC2_TILESET_LAYOUT = { west: [[14, 17], [15, 17]], }, - // TODO rover has layers and moves and stuff - rover: [0, 18], + // TODO rover has an overlay showing its direction + rover: { + inert: [0, 18], + teeth: [[0, 18], [8, 18]], + glider: [ + // quite fast + [0, 18], [1, 18], [2, 18], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], + [0, 18], [1, 18], [2, 18], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18], + ], + bug: [[0, 18], [1, 18], [2, 18], [3, 18], [4, 18], [5, 18], [6, 18], [7, 18]], + ball: [[0, 18], [4, 18]], + teeth_timid: [[0, 18], [9, 18]], + fireball: [ + // quite fast + [7, 18], [6, 18], [5, 18], [4, 18], [3, 18], [2, 18], [1, 18], [0, 18], + [7, 18], [6, 18], [5, 18], [4, 18], [3, 18], [2, 18], [1, 18], [0, 18], + ], + paramecium: [[7, 18], [6, 18], [5, 18], [4, 18], [3, 18], [2, 18], [1, 18], [0, 18]], + walker: [[8, 18], [9, 18]], + }, xray_eye: [11, 18], ghost: { north: [12, 18], diff --git a/js/tiletypes.js b/js/tiletypes.js index 1099fb2..cbfc4ae 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -1733,6 +1733,32 @@ const TILE_TYPES = { blocks_collision: COLLISION.all_but_player, can_reveal_walls: true, movement_speed: 4, + on_ready(me, level) { + me.current_emulatee = 0; + me.attempted_moves = 0; + }, + _emulatees: ['teeth', 'glider', 'bug', 'ball', 'teeth_timid', 'fireball', 'paramecium', 'walker'], + decide_movement(me, level) { + if (me.attempted_moves >= 32) { + level._set_tile_prop(me, 'attempted_moves', me.attempted_moves - 32); + level._set_tile_prop(me, 'current_emulatee', (me.current_emulatee + 1) % me.type._emulatees.length); + } + + me.attempted_moves += 1; + let emulatee = me.type._emulatees[me.current_emulatee]; + let preference = TILE_TYPES[emulatee].decide_movement(me, level); + // TODO need to rig this so a failure counts as two moves + // TODO obeys step while emulating teeth (gah, i guess move that in here too) + return preference; + }, + visual_state(me) { + if (me && me.current_emulatee !== undefined) { + return me.type._emulatees[me.current_emulatee]; + } + else { + return 'inert'; + } + }, }, // Keys, whose behavior varies