we're back at parity now, it looks like
This commit is contained in:
Timothy Stiles 2020-10-14 21:42:51 +11:00
parent 2e1a87199a
commit a8ce3bca11
2 changed files with 9 additions and 3 deletions

View File

@ -655,6 +655,7 @@ class Player extends PrimaryView {
_clear_state() { _clear_state() {
this.set_state('waiting'); this.set_state('waiting');
this.waiting_for_input = false;
this.tic_offset = 0; this.tic_offset = 0;
this.last_advance = 0; this.last_advance = 0;
this.demo_faucet = null; this.demo_faucet = null;
@ -777,10 +778,12 @@ class Player extends PrimaryView {
{ {
if (!this.turn_based || primary_dir != null || input.has('wait')) if (!this.turn_based || primary_dir != null || input.has('wait'))
{ {
this.waiting_for_input = false;
this.level.advance_tic( this.level.advance_tic(
primary_dir, primary_dir,
secondary_dir, secondary_dir,
2); 2);
} }
} }
else //TODO: or `if (!this.waiting_for_input)` to be snappier else //TODO: or `if (!this.waiting_for_input)` to be snappier
@ -840,7 +843,7 @@ class Player extends PrimaryView {
} }
} }
if (this.level.waiting_for_input) if (this.waiting_for_input)
{ {
//freeze tic_offset in time so we don't try to interpolate to the next frame too soon //freeze tic_offset in time so we don't try to interpolate to the next frame too soon
this.tic_offset = 0; this.tic_offset = 0;
@ -861,7 +864,7 @@ class Player extends PrimaryView {
// TODO this is not gonna be right while pausing lol // TODO this is not gonna be right while pausing lol
// 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!
if (this.level.waiting_for_input) { if (this.waiting_for_input) {
//freeze tic_offset in time //freeze tic_offset in time
} }
else else
@ -887,6 +890,7 @@ class Player extends PrimaryView {
// Actually redraw. Used to force drawing outside of normal play // Actually redraw. Used to force drawing outside of normal play
_redraw() { _redraw() {
this.renderer.waiting_for_input = this.waiting_for_input;
this.renderer.draw(this.tic_offset); this.renderer.draw(this.tic_offset);
} }

View File

@ -51,6 +51,8 @@ export class CanvasRenderer {
sx * tw, sy * th, w * tw, h * th, sx * tw, sy * th, w * tw, h * th,
dx * tw, dy * th, w * tw, h * th); dx * tw, dy * th, w * tw, h * th);
} }
waiting_for_input = false;
draw(tic_offset = 0) { draw(tic_offset = 0) {
if (! this.level) { if (! this.level) {
@ -58,7 +60,7 @@ export class CanvasRenderer {
return; return;
} }
let tic = (this.level.tic_counter ?? 0) + tic_offset + (this.level.waiting_for_input ? 1 : 0); let tic = (this.level.tic_counter ?? 0) + tic_offset + (this.waiting_for_input ? 1 : 0);
let tw = this.tileset.size_x; let tw = this.tileset.size_x;
let th = this.tileset.size_y; let th = this.tileset.size_y;
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);