Mostly implement rover

This commit is contained in:
Eevee (Evelyn Woods) 2020-12-06 16:51:24 -07:00
parent 8428572def
commit 30261a106f
2 changed files with 46 additions and 2 deletions

View File

@ -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],

View File

@ -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