Snake
Dependencies: microbit
Fork of microbit_snake by
A Snake Game with animation, score and continuous play
Steps:
- Switch On.
- Snake animation plays.
- Game starts.
- Press buttons to move the snake left, right, up and down.
- Food appears as a dot on the display.
- Try eating the food by manoeuvring Snake to run over it.
- Snake grows as it eats food.
- As it grows it becomes hard to avoid snake biting itself.
- Game Over.
- Snake is flashed and then score is scrolled.
- Game restarts after replaying animation.
Controls:
- Left Button (A)
- If snake moving UP/DOWN moves snake to LEFT.
- If snake moving LEFT moves snake to DOWN.
- If snake moving RIGHT moves snake to UP.
- Right Button (B)
- If snake moving UP/DOWN moves snake to RIGHT.
- If snake moving LEFT moves snake to UP.
- If snake moving RIGHT moves snake to DOWN.
How it looks:
https://www.youtube.com/watch?v=unEs3NOvIKA
Binary to play with
/media/uploads/mazimkhan/microbit_snake_nrf51_microbit.hex
Diff: main.cpp
- Revision:
- 2:38060465e019
- Parent:
- 0:af1bb8b895c7
- Child:
- 3:a0200bceae4b
--- a/main.cpp Sun Apr 10 19:04:55 2016 +0000 +++ b/main.cpp Sun Apr 10 19:20:49 2016 +0000 @@ -235,7 +235,6 @@ void reduce(){ Node<SnakeBone> * tail = bones.removeTail(); - printf ("\r\nNew tail x = %d y = %d\r\n", bones.getTail()->d.getX(), bones.getTail()->d.getY()); if (tail){ delete tail; } @@ -339,7 +338,6 @@ Dimension nextX = snake.getHeadX(); Dimension nextY = snake.getHeadY(); - printf ("\r\nnextx = %d nexty = %d\r\n", (int)nextX, (int)nextY); // Check snake bite if (image.getPixelValue(nextX, nextY) == 15){ @@ -358,7 +356,6 @@ // Switch off end. int endx = snake.getTailX(); int endy = snake.getTailY(); - printf ("\r\nendx = %d endy = %d\r\n", (int)endx, (int)endy); if (endx != -1 && endy != -1){ image.setPixelValue(endx, endy, 0); }