adamjw / SnakeWS

0 stars 1 forks source link

5] Collision with fruit does nothing #5

Closed adamjw closed 9 years ago

adamjw commented 9 years ago

Implement the moveFruit and recolourFruit methods in snake.game.controller.FruitController to allow for fruit to be moved and change colours. Fruit should not occupy spaces that are currently occupies by the snake.

Implement the isCollidingWithFruit in snake.game.controller.CollisionController.

Finally, implement addSegment in snake.game.state.Snake.

The logic should be appropriately added into updateLogic in snake.game.SnakeGame.

Acceptance Criteria:

  1. Upon the snake's head colliding with the fruit, the fruit should change location and colour.
  2. A segment should be added to the snake when it collides with the fruit (it doesn't have to be immediately visible).
  3. The fruit should never spawn in an occupied space (ie: where the snake is).
adamjw commented 9 years ago

For generating the location of the fruit, you'll want a random number generator: http://stackoverflow.com/a/5887736