Fix bugged tail element at 0,0 when first eaten

Fixed array index
  -> prevents render functions from
  accessing uninitialized value in `snake.tail[]`
This commit is contained in:
jonny_jr9 2023-12-17 19:40:42 +01:00
parent 5c72303409
commit 14a66b8e27

View File

@ -36,8 +36,8 @@ void snakeGrow()
game.snake.length++;
// tail part is attached left of last tail part
// maybe problem while rendering --> MUST BE SOLVED THEN
game.snake.tail[game.snake.length][0] = game.snake.tail[game.snake.length - 1][0] - 1;
game.snake.tail[game.snake.length][1] = game.snake.tail[game.snake.length - 1][1];
game.snake.tail[game.snake.length - 1][0] = game.snake.tail[game.snake.length - 2][0];
game.snake.tail[game.snake.length - 1][1] = game.snake.tail[game.snake.length - 2][1];
return;
}