From 2934363bedeb47f4c346191ea88a1e35cbb8f9f9 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Mon, 29 Sep 2025 11:34:40 -0700 Subject: [PATCH] speed up --- app/nose/bin/tetris.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/nose/bin/tetris.ts b/app/nose/bin/tetris.ts index 4b160d0..b61846a 100644 --- a/app/nose/bin/tetris.ts +++ b/app/nose/bin/tetris.ts @@ -1,4 +1,9 @@ /// +// A classic. +// +// Arrow keys move your tetrinome. +// Space bar rotates. +// Enter pauses the game. export const game = true import type { GameContext, InputState } from "@/shared/game" @@ -219,7 +224,7 @@ export function update(_delta: number, input: InputState) { if (++moveTick % MOVE_TICK === 0) detectMovement(input) - if (++downTick % DOWN_TICK === 0) + if (++downTick % downTickForScore() === 0) if (!collision(player.x, player.y + 1, player.rotation)) { player.y++ } @@ -300,6 +305,10 @@ function findFullRows(): number[] { return rows } +function downTickForScore(): number { + return Math.max(1, DOWN_TICK - Math.floor(score / 1000)) +} + function removeClearedLines() { const newGrid: string[][] = [] score += LINE_SCORES[clearedLines.length - 1] || 0