yes
This commit is contained in:
parent
1643dca7a0
commit
413149172b
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user