Git Product home page Git Product logo

pyladies-snake's People

Watchers

 avatar  avatar  avatar

pyladies-snake's Issues

Fruit spawning when there is no place left

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.

Test the code

The game code is currently completely untested. That is absolutely bad practice. Add the tests as soon as possible.

Do not allow the snake to go back through its own body

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

Detect collision with the snake’s own body

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.

Count points – pieces of fruit eaten

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.

Improve fruit spawning

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.

Add README

Even though this is just a demo app, good practices are always good. Add a README to briefly explain what this project is about.

Use different symbol for the snake’s head

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.