fix turn-based mode
This commit is contained in:
parent
1c5f63b61b
commit
f6a79456e9
@ -754,7 +754,10 @@ export class Level extends LevelInterface {
|
||||
|
||||
// Only the Lexy-style loop has a notion of "finishing" a tic, since (unlike the Lynx loop) the
|
||||
// decision phase happens in the /middle/
|
||||
finish_tic() {
|
||||
finish_tic(p1_input) {
|
||||
this.p1_input = p1_input;
|
||||
this.p1_released |= ~p1_input; // Action keys released since we last checked them
|
||||
|
||||
if (this.compat.use_lynx_loop) {
|
||||
return;
|
||||
}
|
||||
|
||||
24
js/main.js
24
js/main.js
@ -1105,6 +1105,7 @@ class Player extends PrimaryView {
|
||||
}
|
||||
|
||||
let has_input = wait || input;
|
||||
let did_finish = false;
|
||||
// Turn-based mode complicates this slightly; it aligns us to the middle of a tic
|
||||
if (this.turn_mode === 2) {
|
||||
if (has_input) {
|
||||
@ -1113,6 +1114,7 @@ class Player extends PrimaryView {
|
||||
// did, the first time we tried it
|
||||
this.level.finish_tic(input);
|
||||
this.turn_mode = 1;
|
||||
did_finish = true;
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
@ -1120,14 +1122,18 @@ class Player extends PrimaryView {
|
||||
}
|
||||
|
||||
// We should now be at the start of a tic
|
||||
this.level.begin_tic(input);
|
||||
if (this.turn_mode > 0 && this.level.can_accept_input() && ! has_input) {
|
||||
// If we're in turn-based mode and could provide input here, but don't have any,
|
||||
// then wait until we do
|
||||
this.turn_mode = 2;
|
||||
}
|
||||
else {
|
||||
this.level.finish_tic(input);
|
||||
// but only start one if we didn't finish one
|
||||
if (!did_finish)
|
||||
{
|
||||
this.level.begin_tic(input);
|
||||
if (this.turn_mode > 0 && this.level.can_accept_input() && !input) {
|
||||
// If we're in turn-based mode and could provide input here, but don't have any,
|
||||
// then wait until we do
|
||||
this.turn_mode = 2;
|
||||
}
|
||||
else {
|
||||
this.level.finish_tic(input);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.level.state !== 'playing') {
|
||||
@ -1204,7 +1210,7 @@ class Player extends PrimaryView {
|
||||
// TODO i'm not sure it'll be right when rewinding either
|
||||
// TODO or if the game's speed changes. wow!
|
||||
let tic_offset;
|
||||
if (this.turn_mode === 2) {
|
||||
if (this.turn_mode === 2 && this.level.can_accept_input()) {
|
||||
// We're dawdling between tics, so nothing is actually animating, but the clock hasn't
|
||||
// advanced yet; pretend whatever's currently animating has finished
|
||||
tic_offset = 0.999;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user