A previous commit should have prevented the snake from changing to the opposite direction, but it did not fix the problem completely. If the user changes the direction of the snake twice in a roll, before any movement occurs, it's still possible to make the snake go to the opposite direction.
A possible fix would be creating a different variable to hold the changed direction, and only apply it to the real one when a movement is made. The keyboard shortcuts would change the direction for this new variable instead.
A previous commit should have prevented the snake from changing to the opposite direction, but it did not fix the problem completely. If the user changes the direction of the snake twice in a roll, before any movement occurs, it's still possible to make the snake go to the opposite direction. A possible fix would be creating a different variable to hold the changed direction, and only apply it to the real one when a movement is made. The keyboard shortcuts would change the direction for this new variable instead.