fixed holes in snake
This commit is contained in:
11
src/App.vue
11
src/App.vue
@@ -86,9 +86,14 @@ function moveSnake(x: number, y: number) {
|
||||
if (snake.value.history.length > length) {
|
||||
const currentLength = snake.value.history.length
|
||||
const allowedLength = snake.value.length
|
||||
const toDelete = snake.value.history.slice(0, currentLength - allowedLength)
|
||||
for (const cell of toDelete) {
|
||||
cell.color = 'white'
|
||||
|
||||
if (currentLength > allowedLength) {
|
||||
const toDelete = snake.value.history.shift()
|
||||
|
||||
if (toDelete !== undefined) {
|
||||
toDelete.color = 'white'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user