spaceface16518 / snake Goto Github PK
View Code? Open in Web Editor NEWThe snake game, in Rust
The snake game, in Rust
This should never happen in practice because it implies that the snake is covering every single tile available. It is a possibility, however, and therefore should be tracked, if nothing else, as a low priority issue.
The real danger with this issue is that the spawn time of the food tile will increase as the number of tiles covered by the snake increase. This shouldn't be a problem besides if a bot or very skilled player advances to a level in which the lag from trying again and again to spawn a food tile makes it hard to play the game. Until that happens, this issue will remain a low priority one.
This issue was caused by code introduced in 89ea28c in order to mitigate #3.
Since food spawning is completely random, it can easily spawn on the snake's body. This can be prevented by checking if a potential spawn location for the food overlaps with the snake's body. The downside to this is iterating over the snake an additional time every time we want to spawn a new piece of food.
By quickly pressing two different keys, the player can move back into itself.
For example, quickly pressing Right
and then Up
while moving the direction Down
will cause the player to move Up
into itself and die.
This is caused by the key event state being out of sync with the update
logic.
The issue could possibly be fixed by either storing an extra direction which would represent the actual direction that the snake is traveling or to remove redundancy, checking the snake's head's direction instead of an arbitrary state that is not actually attached to the snake. If the second route is chosen, GameState
would retain its current state field input_direction
which would be read by update
when choosing a direction and written to by key_down_event
, but key_down_event
would read it's "state" by getting the direction from the snakes head (self.snake.head().direction()
where self
is an instance of GameState
).
This would add an extra element of difficulty to the game besides just the increasing length.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.