Turn-Based: add space to wait
This commit is contained in:
parent
e6a4e88935
commit
5b7273e9d9
10
js/game.js
10
js/game.js
@ -332,14 +332,14 @@ export class Level {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move the game state forwards by one tic
|
// 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') {
|
if (this.state !== 'playing') {
|
||||||
console.warn(`Level.advance_tic() called when state is ${this.state}`);
|
console.warn(`Level.advance_tic() called when state is ${this.state}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this._advance_tic(p1_primary_direction, p1_secondary_direction);
|
this._advance_tic(p1_primary_direction, p1_secondary_direction, force_wait);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (e instanceof GameEnded) {
|
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;
|
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 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) {
|
if (this.waiting_for_input) {
|
||||||
this.actor_decision(this.player, p1_primary_direction);
|
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;
|
skip_to_third_pass = true;
|
||||||
}
|
}
|
||||||
else {
|
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
|
//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;
|
this.waiting_for_input = true;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -341,6 +341,8 @@ class Player extends PrimaryView {
|
|||||||
ArrowRight: 'right',
|
ArrowRight: 'right',
|
||||||
ArrowUp: 'up',
|
ArrowUp: 'up',
|
||||||
ArrowDown: 'down',
|
ArrowDown: 'down',
|
||||||
|
Spacebar: 'wait',
|
||||||
|
" ": 'wait',
|
||||||
w: 'up',
|
w: 'up',
|
||||||
a: 'left',
|
a: 'left',
|
||||||
s: 'down',
|
s: 'down',
|
||||||
@ -764,6 +766,7 @@ class Player extends PrimaryView {
|
|||||||
this.level.advance_tic(
|
this.level.advance_tic(
|
||||||
this.primary_action ? ACTION_DIRECTIONS[this.primary_action] : null,
|
this.primary_action ? ACTION_DIRECTIONS[this.primary_action] : null,
|
||||||
this.secondary_action ? ACTION_DIRECTIONS[this.secondary_action] : null,
|
this.secondary_action ? ACTION_DIRECTIONS[this.secondary_action] : null,
|
||||||
|
input.has('wait')
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.level.state !== 'playing') {
|
if (this.level.state !== 'playing') {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user