diff --git a/app/nose/bin/tetris.ts b/app/nose/bin/tetris.ts index 41f3ae4..4b160d0 100644 --- a/app/nose/bin/tetris.ts +++ b/app/nose/bin/tetris.ts @@ -19,6 +19,7 @@ let player: Shape let nextShape: Shape let grid: string[][] = [] let dead = false +let paused = false let downTick = 0 let moveTick = 0 let clearedLines: number[] = [] @@ -166,6 +167,7 @@ const SHAPES: Record = { } export function init() { + paused = false score = 0 dead = false downTick = 0 @@ -182,6 +184,10 @@ export function init() { export function update(_delta: number, input: InputState) { if (dead) return + if (input.justPressed.has("Enter")) + paused = !paused + if (paused) return + if (input.justPressed.has(" ")) { rotateShape() } @@ -251,9 +257,12 @@ export function draw(game: GameContext) { c.restore() + if (paused) + game.centerTextX("PAUSED", 200, "lime", 60) + // ya dead if (dead) - game.centerText("GAME OVER", "red", 60) + game.centerTextX("GAME OVER", 200, "red", 60) } function spawn() {