ISSUE: Snake collides with itself because inputs are too fast. Fixed. Also implemented wrapped and walls mode modal. #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What: This PR changes a major issue in the snake game in which you can do two inputs at once either resulting in game physics not functioning right or the snake killing itself without even hitting itself by setting a boolean at the top that whenever an input is done the boolean is true and when the game updates the boolean turns false so that another input can be placed.
Why: This matters because you could die in unexpected places resulting in good runs ending and confusing gameplay.
Verified: I verified this by testing the gameplay and confirming that I cannot go left while already going right and by showing that I can use left and up or right and up without dying.
I expected that the snake would correctly move. I observed that the snake didn't function incorrectly crashing into itself without cause.
Status: This PR is ready for review. Next step is merging it with the main, or just using the code from the snake issue as I also created another modal that allows for either a wrapped or walls mode (there is a slight css bug where the modal moves up).