This commit is contained in:
Chris Wanstrath 2025-09-29 11:34:40 -07:00
parent 9a99c7329e
commit 2934363bed

View File

@ -1,4 +1,9 @@
/// <reference lib="dom" /> /// <reference lib="dom" />
// A classic.
//
// Arrow keys move your tetrinome.
// Space bar rotates.
// Enter pauses the game.
export const game = true export const game = true
import type { GameContext, InputState } from "@/shared/game" import type { GameContext, InputState } from "@/shared/game"
@ -219,7 +224,7 @@ export function update(_delta: number, input: InputState) {
if (++moveTick % MOVE_TICK === 0) if (++moveTick % MOVE_TICK === 0)
detectMovement(input) detectMovement(input)
if (++downTick % DOWN_TICK === 0) if (++downTick % downTickForScore() === 0)
if (!collision(player.x, player.y + 1, player.rotation)) { if (!collision(player.x, player.y + 1, player.rotation)) {
player.y++ player.y++
} }
@ -300,6 +305,10 @@ function findFullRows(): number[] {
return rows return rows
} }
function downTickForScore(): number {
return Math.max(1, DOWN_TICK - Math.floor(score / 1000))
}
function removeClearedLines() { function removeClearedLines() {
const newGrid: string[][] = [] const newGrid: string[][] = []
score += LINE_SCORES[clearedLines.length - 1] || 0 score += LINE_SCORES[clearedLines.length - 1] || 0