Skip to content

Commit 8088a99

Browse files
committed
Add a really rudimentary pause button.
1 parent 579d430 commit 8088a99

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/inputs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface PlayerInput {
77
hold: string;
88
}
99
export const inputs = {
10+
pause: "p",
1011
player1: {
1112
left: "a",
1213
right: "d",

src/nodes/Player.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import GatePiece from "./GatePiece";
1717
import { type Level } from "../levels";
1818
import GameNode from "./GameNode";
1919
import { animate } from "motion";
20-
import type { PlayerInput } from "../inputs";
20+
import { inputs, type PlayerInput } from "../inputs";
2121
import { pulse } from "../animations";
2222
import { delay } from "../util";
2323
import { playSound } from "../audio";
@@ -287,6 +287,14 @@ export default class Player extends GameNode {
287287
};
288288

289289
onPress = (key: string) => {
290+
if (key === inputs.pause) {
291+
if (this.currentState === "game") {
292+
this.currentState = "pause";
293+
} else {
294+
this.currentState = "game";
295+
}
296+
return;
297+
}
290298
if (this.currentState !== "game") {
291299
return;
292300
}

0 commit comments

Comments
 (0)