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:
parent
5c72303409
commit
14a66b8e27
@ -36,8 +36,8 @@ void snakeGrow()
|
|||||||
game.snake.length++;
|
game.snake.length++;
|
||||||
// tail part is attached left of last tail part
|
// tail part is attached left of last tail part
|
||||||
// maybe problem while rendering --> MUST BE SOLVED THEN
|
// 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][0] = game.snake.tail[game.snake.length - 2][0];
|
||||||
game.snake.tail[game.snake.length][1] = game.snake.tail[game.snake.length - 1][1];
|
game.snake.tail[game.snake.length - 1][1] = game.snake.tail[game.snake.length - 2][1];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user