Split up the Steam loop into begin/finish parts to match what turn-based mode expects
This commit is contained in:
1 parent
f0cd4d3c5a
commit
4454970564
2 files changed
+18
-18
No files matched your search
+8
-2
@@ -697,7 +697,7 @@ export class Level extends LevelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.begin_tic(p1_input);
|
this.begin_tic(p1_input);
|
||||||
this.finish_tic();
|
this.finish_tic(p1_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME a whole bunch of these comments are gonna be wrong or confusing now
|
// FIXME a whole bunch of these comments are gonna be wrong or confusing now
|
||||||
@@ -760,6 +760,9 @@ export class Level extends LevelInterface {
|
|||||||
this.p1_released |= ~p1_input; // Action keys released since we last checked them
|
this.p1_released |= ~p1_input; // Action keys released since we last checked them
|
||||||
|
|
||||||
if (this.compat.use_lynx_loop) {
|
if (this.compat.use_lynx_loop) {
|
||||||
|
if (this.compat.emulate_60fps) {
|
||||||
|
this._finish_tic_lynx60();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -851,7 +854,10 @@ export class Level extends LevelInterface {
|
|||||||
this._do_combined_action_phase(1, true);
|
this._do_combined_action_phase(1, true);
|
||||||
this._do_wire_phase();
|
this._do_wire_phase();
|
||||||
this._do_static_phase();
|
this._do_static_phase();
|
||||||
|
}
|
||||||
|
// This is in the "finish" part to preserve the property turn-based mode expects, where "finish"
|
||||||
|
// picks up right when the player could provide input
|
||||||
|
_finish_tic_lynx60() {
|
||||||
this._do_decision_phase();
|
this._do_decision_phase();
|
||||||
this._do_combined_action_phase(1);
|
this._do_combined_action_phase(1);
|
||||||
this._do_wire_phase();
|
this._do_wire_phase();
|
||||||
|
|||||||
+10
-16
@@ -1105,7 +1105,6 @@ class Player extends PrimaryView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let has_input = wait || input;
|
let has_input = wait || input;
|
||||||
let did_finish = false;
|
|
||||||
// Turn-based mode complicates this slightly; it aligns us to the middle of a tic
|
// Turn-based mode complicates this slightly; it aligns us to the middle of a tic
|
||||||
if (this.turn_mode === 2) {
|
if (this.turn_mode === 2) {
|
||||||
if (has_input) {
|
if (has_input) {
|
||||||
@@ -1114,7 +1113,6 @@ class Player extends PrimaryView {
|
|||||||
// did, the first time we tried it
|
// did, the first time we tried it
|
||||||
this.level.finish_tic(input);
|
this.level.finish_tic(input);
|
||||||
this.turn_mode = 1;
|
this.turn_mode = 1;
|
||||||
did_finish = true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
@@ -1122,18 +1120,14 @@ class Player extends PrimaryView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We should now be at the start of a tic
|
// We should now be at the start of a tic
|
||||||
// but only start one if we didn't finish one
|
this.level.begin_tic(input);
|
||||||
if (!did_finish)
|
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,
|
||||||
this.level.begin_tic(input);
|
// then wait until we do
|
||||||
if (this.turn_mode > 0 && this.level.can_accept_input() && !input) {
|
this.turn_mode = 2;
|
||||||
// If we're in turn-based mode and could provide input here, but don't have any,
|
}
|
||||||
// then wait until we do
|
else {
|
||||||
this.turn_mode = 2;
|
this.level.finish_tic(input);
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.level.finish_tic(input);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.level.state !== 'playing') {
|
if (this.level.state !== 'playing') {
|
||||||
@@ -1148,7 +1142,7 @@ class Player extends PrimaryView {
|
|||||||
this.debug.replay_custom_label.textContent = format_replay_duration(this.debug.custom_replay.duration);
|
this.debug.replay_custom_label.textContent = format_replay_duration(this.debug.custom_replay.duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main driver of the level; advances by one tic, then schedules itself to
|
// Main driver of the level; advances by one tic, then schedules itself to
|
||||||
// be called again next tic
|
// be called again next tic
|
||||||
advance() {
|
advance() {
|
||||||
@@ -1210,7 +1204,7 @@ class Player extends PrimaryView {
|
|||||||
// TODO i'm not sure it'll be right when rewinding either
|
// TODO i'm not sure it'll be right when rewinding either
|
||||||
// TODO or if the game's speed changes. wow!
|
// TODO or if the game's speed changes. wow!
|
||||||
let tic_offset;
|
let tic_offset;
|
||||||
if (this.turn_mode === 2 && this.level.can_accept_input()) {
|
if (this.turn_mode === 2) {
|
||||||
// We're dawdling between tics, so nothing is actually animating, but the clock hasn't
|
// We're dawdling between tics, so nothing is actually animating, but the clock hasn't
|
||||||
// advanced yet; pretend whatever's currently animating has finished
|
// advanced yet; pretend whatever's currently animating has finished
|
||||||
tic_offset = 0.999;
|
tic_offset = 0.999;
|
||||||
|
|||||||
Reference in new issue
Block a user