From 7c82a4cdf92a883dc73e80232612321a8add2ee7 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Tue, 15 Dec 2020 01:07:02 -0700 Subject: [PATCH] Only do CC2 actions per press, not per held tic --- js/game.js | 10 +++++++--- js/main.js | 5 ----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/js/game.js b/js/game.js index fdcb799..ffb41fa 100644 --- a/js/game.js +++ b/js/game.js @@ -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 diff --git a/js/main.js b/js/main.js index 4836879..bca0d08 100644 --- a/js/main.js +++ b/js/main.js @@ -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