Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You can still turn 180° sometimes #3

Closed
graue opened this issue Oct 19, 2013 · 1 comment
Closed

You can still turn 180° sometimes #3

graue opened this issue Oct 19, 2013 · 1 comment

Comments

@graue
Copy link
Owner

graue commented Oct 19, 2013

Killing yourself by turning 180° is supposed to be prevented, but you can still do it. Assume you're going left. Quickly press down or up followed by right. If game logic hasn't run in between the two key-presses, you don't move vertically and so run into your tail right away.

To fix this, we should save the direction that was last advanced in (by a pixel or more after flooring), and disallow turning in the opposite of that direction.

graue added a commit that referenced this issue Nov 6, 2013
The other part is to advance the snake only by entire pixels at a time.
You can still trigger the bug if you are going right, press up/down,
"advance" 0.3333 pixels then press left, and the floor of your new
location equals the floor of the old. This is because using a position
variable with more precision than our collision-detecting routine is
silly :)
@graue
Copy link
Owner Author

graue commented Nov 6, 2013

Partially fixed in b6ff992.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant