[BUG] Snake turns to wrong direction -- Fixed#507
Conversation
|
So, this PR fixes a bug where pressing the left arrow (or A) at the very start of the game would incorrectly turn the snake to the right. The snake was initialized with initial_dx = 1, meaning it always had an initial orientation to the right, even when speed was zero. I prevented the original bug, through changing the initial orientation of the snake sprite to the right. |
JeanJPNM
left a comment
There was a problem hiding this comment.
This doesn't really fix the problem, now if someone wants to start with the up arrow (or w) the same thing will happen
|
@JeanJPNM I don't think I understand your proposition. What I did was align the sprite with its initially assigned orientation in the code. So, whenever the game starts, the snake is turned to the right, and will respond as it should. The rest of the game stays exactly the same. I just tested, and it doesn't have any error if the up-arrow is pressed, nor any other possible direction (down, or right). |
JeanJPNM
left a comment
There was a problem hiding this comment.
My bad, I forgot to take the sprite into consideration.
So, there was an error (issue #500 ) that if you started the game, and specifically pressed the left-arrow or A-button, the snake would turn to the right instead of left.
It was because of this piece of code, localized on prefabs/snake.py:
It initialized the initial_dx with 1, that meant to move right.
The fix sets the initial direction to (0, 0) when the game starts in manual mode, so the first user input defines the direction.