3 ms·
Bug: Create snake of length two. Move RIGHT. Quickly press UP LEFT in quick succession. Lose. Similar bug with RIGHT->DOWN->LEFT And so on for all the other i
by dyarosla 9y ago
Bug: Create snake of length two. Move RIGHT. Quickly press UP LEFT in quick succession. Lose.
Similar bug with RIGHT->DOWN->LEFT
And so on for all the other initial directions.
- KurtMueller 9y agoWhy not file a Github issue? :)
- dyarosla 9y agoDone
- fb03 9y agoNot the author, but I've implemented my own snake game and this bug is fairly easy to kill. (1) - You can only change directions that will change your axis, if you're going left your possible changes are up and down, .... (2) - You should be only able to consume one direction change per game tick, what is happening here is that rule (1) is working but you can change into the other axis, and then back to the other axis again before the game loop computes another frame. Direction change can be read asynchronously but the actual change should be tied by each tick.
- baddox 9y agoMaybe it makes it too easy, but I would enjoy the mechanic that quickly pressing UP LEFT when moving right would make the snake head move one square up then turn left and continue left. I suppose that would require some special casing, and you wouldn't want to support longer queued direction changes. Maybe a nice implementation would be that for inputs queued within a single game tick, execute the first input for one square of movement, then the last input for the next tick.
- fareesh 9y agoYeah happened to me too, thought it was my mistake but now I blame the bug :D