Implement walkers, blobs, and teeth
This commit is contained in:
parent
aa7952a3dd
commit
4d6d835895
42
js/main.js
42
js/main.js
@ -379,6 +379,10 @@ class Level {
|
|||||||
actor.last_move_was_force = false;
|
actor.last_move_was_force = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (actor.type.movement_mode === 'forward') {
|
||||||
|
// blue tank behavior: keep moving forward
|
||||||
|
direction_preference = [actor.direction];
|
||||||
|
}
|
||||||
else if (actor.type.movement_mode === 'follow-left') {
|
else if (actor.type.movement_mode === 'follow-left') {
|
||||||
// bug behavior: always try turning as left as possible, and
|
// bug behavior: always try turning as left as possible, and
|
||||||
// fall back to less-left turns when that fails
|
// fall back to less-left turns when that fails
|
||||||
@ -409,9 +413,41 @@ class Level {
|
|||||||
let d = DIRECTIONS[actor.direction];
|
let d = DIRECTIONS[actor.direction];
|
||||||
direction_preference = [actor.direction, d.opposite];
|
direction_preference = [actor.direction, d.opposite];
|
||||||
}
|
}
|
||||||
else if (actor.type.movement_mode === 'forward') {
|
else if (actor.type.movement_mode === 'bounce-random') {
|
||||||
// blue tank behavior: keep moving forward
|
// walker behavior: preserve current direction; if that
|
||||||
direction_preference = [actor.direction];
|
// doesn't work, pick a random direction, even the one we
|
||||||
|
// failed to move in
|
||||||
|
// TODO unclear if this is right in cc2 as well. definitely not in ms, which chooses a legal move
|
||||||
|
direction_preference = [actor.direction, ['north', 'south', 'east', 'west'][Math.floor(Math.random() * 4)]];
|
||||||
|
}
|
||||||
|
else if (actor.type.movement_mode === 'pursue') {
|
||||||
|
// teeth behavior: always move towards the player
|
||||||
|
let dx = actor.x - this.player.x;
|
||||||
|
let dy = actor.y - this.player.y;
|
||||||
|
// Chooses the furthest direction, vertical wins ties
|
||||||
|
if (Math.abs(dx) > Math.abs(dy)) {
|
||||||
|
// Horizontal
|
||||||
|
if (dx > 0) {
|
||||||
|
direction_preference = ['west'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
direction_preference = ['east'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Vertical
|
||||||
|
if (dy > 0) {
|
||||||
|
direction_preference = ['north'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
direction_preference = ['south'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (actor.type.movement_mode === 'random') {
|
||||||
|
// blob behavior: move completely at random
|
||||||
|
// TODO cc2 has twiddles for how this works per-level, as well as the initial seed for demo playback
|
||||||
|
direction_preference = [['north', 'south', 'east', 'west'][Math.floor(Math.random() * 4)]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! direction_preference)
|
if (! direction_preference)
|
||||||
|
|||||||
@ -417,7 +417,7 @@ const TILE_TYPES = {
|
|||||||
is_object: true,
|
is_object: true,
|
||||||
is_monster: true,
|
is_monster: true,
|
||||||
blocks_monsters: true,
|
blocks_monsters: true,
|
||||||
// TODO movement_move: 'bounce-random',
|
movement_mode: 'bounce-random',
|
||||||
movement_speed: 4,
|
movement_speed: 4,
|
||||||
},
|
},
|
||||||
tank_blue: {
|
tank_blue: {
|
||||||
@ -433,6 +433,7 @@ const TILE_TYPES = {
|
|||||||
is_object: true,
|
is_object: true,
|
||||||
is_monster: true,
|
is_monster: true,
|
||||||
blocks_monsters: true,
|
blocks_monsters: true,
|
||||||
|
movement_mode: 'random',
|
||||||
movement_speed: 8,
|
movement_speed: 8,
|
||||||
},
|
},
|
||||||
teeth: {
|
teeth: {
|
||||||
@ -440,7 +441,9 @@ const TILE_TYPES = {
|
|||||||
is_object: true,
|
is_object: true,
|
||||||
is_monster: true,
|
is_monster: true,
|
||||||
blocks_monsters: true,
|
blocks_monsters: true,
|
||||||
movement_speed: 4,
|
movement_mode: 'pursue',
|
||||||
|
// TODO actually 4 with deliberate pauses but i have no way to model that atm
|
||||||
|
movement_speed: 8,
|
||||||
},
|
},
|
||||||
fireball: {
|
fireball: {
|
||||||
is_actor: true,
|
is_actor: true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user