Only do CC2 actions per press, not per held tic
This commit is contained in:
parent
0f02e270f2
commit
7c82a4cdf9
10
js/game.js
10
js/game.js
@ -318,6 +318,7 @@ export class Level {
|
|||||||
|
|
||||||
this.cells = [];
|
this.cells = [];
|
||||||
this.player = null;
|
this.player = null;
|
||||||
|
this.previous_input = 0;
|
||||||
this.actors = [];
|
this.actors = [];
|
||||||
this.chips_remaining = this.stored_level.chips_required;
|
this.chips_remaining = this.stored_level.chips_required;
|
||||||
this.bonus_points = 0;
|
this.bonus_points = 0;
|
||||||
@ -678,13 +679,14 @@ export class Level {
|
|||||||
|
|
||||||
// Check for special player actions, which can only happen when not moving
|
// Check for special player actions, which can only happen when not moving
|
||||||
if (actor === this.player) {
|
if (actor === this.player) {
|
||||||
if (p1_input & INPUT_BITS.cycle) {
|
let new_input = p1_input & ~this.previous_input;
|
||||||
|
if (new_input & INPUT_BITS.cycle) {
|
||||||
this.cycle_inventory(this.player);
|
this.cycle_inventory(this.player);
|
||||||
}
|
}
|
||||||
if (p1_input & INPUT_BITS.drop) {
|
if (new_input & INPUT_BITS.drop) {
|
||||||
this.drop_item(this.player);
|
this.drop_item(this.player);
|
||||||
}
|
}
|
||||||
if (p1_input & INPUT_BITS.swap) {
|
if (new_input & INPUT_BITS.swap) {
|
||||||
// This is delayed until the end of the tic to avoid screwing up anything
|
// This is delayed until the end of the tic to avoid screwing up anything
|
||||||
// checking this.player
|
// checking this.player
|
||||||
swap_player1 = true;
|
swap_player1 = true;
|
||||||
@ -747,6 +749,8 @@ export class Level {
|
|||||||
this.player = this.players[this.player_index];
|
this.player = this.players[this.player_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.previous_input = p1_input;
|
||||||
|
|
||||||
// Advance the clock
|
// Advance the clock
|
||||||
// TODO i suspect cc2 does this at the beginning of the tic, but even if you've won? if you
|
// TODO i suspect cc2 does this at the beginning of the tic, but even if you've won? if you
|
||||||
// step on a penalty + exit you win, but you see the clock flicker 1 for a single frame
|
// step on a penalty + exit you win, but you see the clock flicker 1 for a single frame
|
||||||
|
|||||||
@ -441,7 +441,6 @@ class Player extends PrimaryView {
|
|||||||
this.next_player_move = null;
|
this.next_player_move = null;
|
||||||
this.player_used_move = false;
|
this.player_used_move = false;
|
||||||
let key_target = document.body;
|
let key_target = document.body;
|
||||||
this.previous_input = new Set; // actions that were held last tic
|
|
||||||
this.using_touch = false; // true if using touch controls
|
this.using_touch = false; // true if using touch controls
|
||||||
this.current_keys = new Set; // keys that are currently held
|
this.current_keys = new Set; // keys that are currently held
|
||||||
this.current_keys_new = new Set; // keys that were pressed since input was last read
|
this.current_keys_new = new Set; // keys that were pressed since input was last read
|
||||||
@ -1106,10 +1105,6 @@ class Player extends PrimaryView {
|
|||||||
this.debug.replay.set(this.level.tic_counter, input);
|
this.debug.replay.set(this.level.tic_counter, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME cycle/drop/swap depend on this but that's currently broken; should Level handle
|
|
||||||
// it? probably
|
|
||||||
this.previous_input = input;
|
|
||||||
|
|
||||||
this.sfx_player.advance_tic();
|
this.sfx_player.advance_tic();
|
||||||
|
|
||||||
// Turn-based mode is considered assistance, but only if the game actually attempts to
|
// Turn-based mode is considered assistance, but only if the game actually attempts to
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user