Fix bumping to only happen on departure; add a CC2 input tiebreaker
This commit is contained in:
parent
045bcb5789
commit
67228d89d1
38
js/game.js
38
js/game.js
@ -538,11 +538,31 @@ export class Level {
|
||||
continue;
|
||||
|
||||
this.set_actor_direction(actor, actor.decision);
|
||||
let old_cell = actor.cell;
|
||||
this.attempt_step(actor, actor.decision);
|
||||
|
||||
// TODO do i need to do this more aggressively?
|
||||
if (this.state === 'success' || this.state === 'failure')
|
||||
break;
|
||||
|
||||
// Players can also bump the tiles in the cell next to the one they're leaving
|
||||
if (actor.type.is_player && actor.secondary_direction) {
|
||||
let neighbor = this.cell_with_offset(old_cell, actor.secondary_direction);
|
||||
if (neighbor) {
|
||||
for (let tile of neighbor) {
|
||||
// TODO only works if tile can be entered!
|
||||
// TODO repeating myself with tile.stuck (also should technically check for actor)
|
||||
if (actor.type.pushes && actor.type.pushes[tile.type.name] && tile.movement_cooldown === 0 && ! tile.stuck) {
|
||||
// Block slapping: you can shove a block by walking past it sideways
|
||||
this.set_actor_direction(tile, actor.secondary_direction);
|
||||
this.attempt_step(tile, actor.secondary_direction);
|
||||
}
|
||||
else if (tile.type.on_bump) {
|
||||
tile.type.on_bump(tile, this, actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Strip out any destroyed actors from the acting order
|
||||
@ -766,24 +786,6 @@ export class Level {
|
||||
}
|
||||
}
|
||||
|
||||
// Players can also bump the tiles next to where they landed
|
||||
if (actor.type.is_player && actor.secondary_direction) {
|
||||
let neighbor = this.cell_with_offset(actor.cell, actor.secondary_direction);
|
||||
if (neighbor) {
|
||||
for (let tile of neighbor) {
|
||||
// TODO repeating myself with tile.stuck (also should technically check for actor)
|
||||
if (actor.type.pushes && actor.type.pushes[tile.type.name] && tile.movement_cooldown === 0 && ! tile.stuck) {
|
||||
// Block slapping: you can shove a block by walking past it sideways
|
||||
this.set_actor_direction(tile, actor.secondary_direction);
|
||||
this.attempt_step(tile, actor.secondary_direction);
|
||||
}
|
||||
else if (tile.type.on_bump) {
|
||||
tile.type.on_bump(tile, this, actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle teleporting, now that the dust has cleared
|
||||
// FIXME something funny happening here, your input isn't ignore while walking out of it?
|
||||
if (teleporter) {
|
||||
|
||||
11
js/main.js
11
js/main.js
@ -444,6 +444,14 @@ class Player extends PrimaryView {
|
||||
// way, act like we're starting from scratch and check keys in priority order
|
||||
this.primary_action = null;
|
||||
this.secondary_action = null;
|
||||
|
||||
// As a tiebreaker, first check if we're holding the key corresponding to the
|
||||
// player's facing direction
|
||||
let player_facing_action = DIRECTIONS[this.level.player.direction].action;
|
||||
if (input.has(player_facing_action)) {
|
||||
this.primary_action = player_facing_action;
|
||||
}
|
||||
|
||||
for (let action of ['down', 'left', 'right', 'up']) {
|
||||
if (! input.has(action))
|
||||
continue;
|
||||
@ -451,10 +459,11 @@ class Player extends PrimaryView {
|
||||
if (! this.primary_action) {
|
||||
this.primary_action = action;
|
||||
}
|
||||
else {
|
||||
else if (action !== this.primary_action) {
|
||||
// Note that because of the opposing keys check, there can never be more
|
||||
// than two keys held down here
|
||||
this.secondary_action = action;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user