This commit is contained in:
Chris Wanstrath 2025-09-28 18:36:57 -07:00
parent 1643dca7a0
commit 413149172b

View File

@ -39,14 +39,10 @@ export function update(_delta: number, input: InputState) {
const head = { x: snake[0]!.x + dir.x, y: snake[0]!.y + dir.y } const head = { x: snake[0]!.x + dir.x, y: snake[0]!.y + dir.y }
// death checks // death checks
if ( dead = head.x < 0 || head.x >= WIDTH || head.y < 0 || head.y >= HEIGHT ||
head.x < 0 || head.x >= WIDTH ||
head.y < 0 || head.y >= HEIGHT ||
snake.some(s => s.x === head.x && s.y === head.y) snake.some(s => s.x === head.x && s.y === head.y)
) {
dead = true if (dead) return
return
}
snake.unshift(head) snake.unshift(head)