glutexo / pyladies-snake Goto Github PK
View Code? Open in Web Editor NEWMy approach to a Snake game for consideration in the upcoming PyLadies course
My approach to a Snake game for consideration in the upcoming PyLadies course
When there are no free coordinates in the field, it is unable for a new piece of fruit to spawn. The game halts in an infinite loop.
In this case, a new piece of fruit shall not appear. The field is probably completely filled by the snake’s body and the game will be over in the next turn.
For this to be possible, a more clever fruit spawning mechanism is needed. See #1.
The game code is currently completely untested. That is absolutely bad practice. Add the tests as soon as possible.
There is no collision detection of the snake body. It is possible to slither through, even in a direction opposite of the last. That makes the snake go all the way through its own body. This doesn’t really make sense, but shall not be considered a collision.
Example:
. X . . . . . . .
. X . ↓ . X . ↓ . X .
. . . . . . . X .
See #4
The snake can slither through its own body. Instead of that, collision should be detected making the game to be over. This does not apply for driving the snake backwards – to the direction opposite to the previous slither. See #3.
A game should be rewarding. For every piece of fruit eaten the player should gain one point. The total number of points should be displayed along the game field.
Fruit spawning is not very clever. Random coordinates are generated. If these coordinates are occupied, the randomness continues until we are lucky. This approach is not good and becomes highly inefficient when the fields becomes almost full.
Improve this by populating occupied/free fields. Then, pick a random place for a piece of fruit to spawn from the list of free fields. There will be no more risk of infinite looping. See #2.
Even though this is just a demo app, good practices are always good. Add a README to briefly explain what this project is about.
Currently, all parts of the snake’s body are represented by an X
. This makes it impossible to see where its head is. This can even lead to an unwanted Game Over making it really bad user experience.
Currently the thing type is used to determine the image used. This is no longer sufficent. Snake is still a snake, but different symbols are needed to draw its parts.
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.