From 5b7273e9d9948faacaf621f8c19c0cfe620d2e4e Mon Sep 17 00:00:00 2001 From: Timothy Stiles Date: Sat, 26 Sep 2020 22:40:38 +1000 Subject: [PATCH] Turn-Based: add space to wait --- js/game.js | 10 +++++----- js/main.js | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/game.js b/js/game.js index 3697033..216a9e9 100644 --- a/js/game.js +++ b/js/game.js @@ -332,14 +332,14 @@ export class Level { } // Move the game state forwards by one tic - advance_tic(p1_primary_direction, p1_secondary_direction) { + advance_tic(p1_primary_direction, p1_secondary_direction, force_wait) { if (this.state !== 'playing') { console.warn(`Level.advance_tic() called when state is ${this.state}`); return; } try { - this._advance_tic(p1_primary_direction, p1_secondary_direction); + this._advance_tic(p1_primary_direction, p1_secondary_direction, force_wait); } catch (e) { if (e instanceof GameEnded) { @@ -356,13 +356,13 @@ export class Level { } } - _advance_tic(p1_primary_direction, p1_secondary_direction) { + _advance_tic(p1_primary_direction, p1_secondary_direction, force_wait) { var skip_to_third_pass = false; //if we're waiting for input, then we want to skip straight to phase 3 with a player decision filled out when they have one ready if (this.waiting_for_input) { this.actor_decision(this.player, p1_primary_direction); - if (this.player.decision != null) { + if (this.player.decision != null || force_wait) { skip_to_third_pass = true; } else { @@ -442,7 +442,7 @@ export class Level { } //in Turn-Based mode, wait for input if the player can voluntarily move on tic_counter % 4 == 0 and isn't - if (this.turn_based && this.player.movement_cooldown == 0 && this.player.decision == null && this.tic_counter % 4 == 0) + if (this.turn_based && this.player.movement_cooldown == 0 && this.player.decision == null && (this.tic_counter % 4 == 0) && !force_wait) { this.waiting_for_input = true; return; diff --git a/js/main.js b/js/main.js index 773a2a8..d20d983 100644 --- a/js/main.js +++ b/js/main.js @@ -341,6 +341,8 @@ class Player extends PrimaryView { ArrowRight: 'right', ArrowUp: 'up', ArrowDown: 'down', + Spacebar: 'wait', + " ": 'wait', w: 'up', a: 'left', s: 'down', @@ -764,6 +766,7 @@ class Player extends PrimaryView { this.level.advance_tic( this.primary_action ? ACTION_DIRECTIONS[this.primary_action] : null, this.secondary_action ? ACTION_DIRECTIONS[this.secondary_action] : null, + input.has('wait') ); if (this.level.state !== 'playing') {