Code Monkey home page Code Monkey logo

snake's People

Contributors

dominikjasek avatar pilkaj avatar

Watchers

 avatar

snake's Issues

Get player input

Resolve issue with getting input from player. multiple consequent inputs must be remembered. Let's say 3.
Use enumerator class 'Directions' for enumerating inputs.

Cleanup

Do cleanup. remove unused functions as:

  • updateDirection
  • updatejoints
  • isjointdistancevalid
  • jointdistance

Create own file for every class, as are joint, snake, snakegame

Enlarge snake

Create snake self function to enlarge its body.
New joint should be placed at the tail.

Eating fruit

Validate whether the snake eat a fruit.
Create function in class Snakegame with input params snake and fruits.
Return True or False value.

Game menu - basic

Create game menu. Basic implementation will contain two screens. We are OK with it for now.

Main menu - displayed, when app is started:
<Play game button>

Game finish menu - displayed when game has finished:
<score label> <total_time label>
<OK button>

Apply player input

Check input validity - whether new direction does not collide with snake body.
Update snake self variable direction.

Snake movement

Do basic snake movement based on the snake direction and current position.
Update snake self joints positions.

Use queue system FIFO, when tail becomes head with new coordinates.

Restrict fruit randomizer

Restrict fruit randomizer in generating fruits on positions, where there are already some objects as snake, wall, or other fruit.

Snake collision detection

Situations to be tested:

  • did snake collide with the wall?
  • screen boundary - either collide or continue on the opposite side of the screen
  • did snake collide with itself?

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.