Do not unpause visualizer when using arrow keys
This commit is contained in:
parent
5c20f19c8a
commit
949844b957
1 changed files with 13 additions and 40 deletions
|
@ -361,7 +361,6 @@ export class GameInstance {
|
||||||
|
|
||||||
this.planet_labels[i].setText(
|
this.planet_labels[i].setText(
|
||||||
GL,
|
GL,
|
||||||
// this.planet_names[i] + " " +
|
|
||||||
"" + planet_ships[i],
|
"" + planet_ships[i],
|
||||||
Align.Middle,
|
Align.Middle,
|
||||||
Align.Begin
|
Align.Begin
|
||||||
|
@ -563,15 +562,8 @@ export class GameInstance {
|
||||||
|
|
||||||
updateTurn(turn: number) {
|
updateTurn(turn: number) {
|
||||||
this.frame = Math.max(0, turn);
|
this.frame = Math.max(0, turn);
|
||||||
const new_frame = this.game.update_turn(this.frame);
|
this.game.update_turn(this.frame);
|
||||||
if (new_frame < this.frame) {
|
|
||||||
this.frame = new_frame;
|
|
||||||
this.playing = false;
|
|
||||||
} else {
|
|
||||||
this._update_state();
|
this._update_state();
|
||||||
this.playing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateTurnCounters();
|
this.updateTurnCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,36 +575,17 @@ export class GameInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKey(event: KeyboardEvent) {
|
handleKey(event: KeyboardEvent) {
|
||||||
// Space
|
let delta = event.shiftKey ? 5 : 1;
|
||||||
if (event.keyCode == 32) {
|
switch (event.code) {
|
||||||
if (this.playing) {
|
case "Space":
|
||||||
this.playing = false;
|
this.playing = !this.playing;
|
||||||
} else {
|
break;
|
||||||
this.playing = true;
|
case "ArrowLeft":
|
||||||
}
|
this.updateTurn(this.frame - delta);
|
||||||
}
|
break;
|
||||||
|
case "ArrowRight":
|
||||||
// Arrow left
|
this.updateTurn(this.frame + delta);
|
||||||
if (event.keyCode == 37) {
|
break;
|
||||||
// This feels more natural than -1 what it should be, I think
|
|
||||||
this.updateTurn(this.frame - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Arrow right
|
|
||||||
if (event.keyCode == 39) {
|
|
||||||
this.updateTurn(this.frame + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// d key
|
|
||||||
if (event.keyCode == 68) {
|
|
||||||
ELEMENTS["speed"].value = ms_per_frame + 10 + "";
|
|
||||||
ELEMENTS["speed"].onchange(undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
// a key
|
|
||||||
if (event.keyCode == 65) {
|
|
||||||
ELEMENTS["speed"].value = Math.max(ms_per_frame - 10, 0) + "";
|
|
||||||
ELEMENTS["speed"].onchange(undefined);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue