Only do CC2 actions per press, not per held tic

This commit is contained in:
Eevee (Evelyn Woods) 2020-12-15 01:07:02 -07:00
parent 0f02e270f2
commit 7c82a4cdf9
2 changed files with 7 additions and 8 deletions

View File

@ -318,6 +318,7 @@ export class Level {
this.cells = [];
this.player = null;
this.previous_input = 0;
this.actors = [];
this.chips_remaining = this.stored_level.chips_required;
this.bonus_points = 0;
@ -678,13 +679,14 @@ export class Level {
// Check for special player actions, which can only happen when not moving
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);
}
if (p1_input & INPUT_BITS.drop) {
if (new_input & INPUT_BITS.drop) {
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
// checking this.player
swap_player1 = true;
@ -747,6 +749,8 @@ export class Level {
this.player = this.players[this.player_index];
}
this.previous_input = p1_input;
// Advance the clock
// 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

View File

@ -441,7 +441,6 @@ class Player extends PrimaryView {
this.next_player_move = null;
this.player_used_move = false;
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.current_keys = new Set; // keys that are currently held
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);
}
// 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();
// Turn-based mode is considered assistance, but only if the game actually attempts to