speed up
This commit is contained in:
parent
9a99c7329e
commit
2934363bed
|
|
@ -1,4 +1,9 @@
|
|||
/// <reference lib="dom" />
|
||||
// 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user