Simon Atkinson 201255483

Dependencies:   mbed

Snake Game

Summary

Hello and welcome to my Snake Game. Snake is a simple game where you control a snake and eat an apple which increases your size. Normally touching the walls will kill you, always touching yourself will make you die!

Controls

The Controls for this game are simple the Start button starts the game (who would have thought) this button is the left button on the bottom of the gamepad next to the two blue potentiometers. The Reset button on the right of the potentiometers resets the game. Once the game starts use the left thumbstick to control the movement of the snake.

If you hit the wall with your snake you will die and the game will end.

Bugs/Missing Features

Unfortunatley I wasn't able to get the game eating the apple to work, when I tried I could never get it to detect the collisions I tried a few different ways but ran out of time. Because that doesn't work the score doesn't increase and the apple doesn't spawn in a different place. I will try continue to work on this when I have time as I enjoyed doing this project even though it was very frustrating at times!

Committer:
Psy1990
Date:
Fri Jun 05 06:29:17 2020 +0000
Revision:
8:32825d724856
Child:
9:25597bc0cecc
Moved everything into classes, still trying to get everything to work. So far the snake object and apple can spawn but not in the right place :(

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Psy1990 8:32825d724856 1 #ifndef Snake_H
Psy1990 8:32825d724856 2 #define Snake_H
Psy1990 8:32825d724856 3
Psy1990 8:32825d724856 4 #include "mbed.h"
Psy1990 8:32825d724856 5 #include "N5110.h"
Psy1990 8:32825d724856 6 #include "Gamepad.h"
Psy1990 8:32825d724856 7
Psy1990 8:32825d724856 8
Psy1990 8:32825d724856 9 class Snake
Psy1990 8:32825d724856 10 {
Psy1990 8:32825d724856 11 public:
Psy1990 8:32825d724856 12
Psy1990 8:32825d724856 13 Snake();
Psy1990 8:32825d724856 14 ~Snake();
Psy1990 8:32825d724856 15 void init(int _x, int _y, int _speed);
Psy1990 8:32825d724856 16 void draw(N5110 &lcd);
Psy1990 8:32825d724856 17 void update();
Psy1990 8:32825d724856 18 void read_input(Gamepad &pad);
Psy1990 8:32825d724856 19 void update(Direction d,float mag);
Psy1990 8:32825d724856 20 void add_score();
Psy1990 8:32825d724856 21 int get_score();
Psy1990 8:32825d724856 22 Vector2D get_pos();
Psy1990 8:32825d724856 23 Vector2D get_Direction();
Psy1990 8:32825d724856 24
Psy1990 8:32825d724856 25 private:
Psy1990 8:32825d724856 26
Psy1990 8:32825d724856 27 int _x;
Psy1990 8:32825d724856 28 int _y;
Psy1990 8:32825d724856 29 int _speed;
Psy1990 8:32825d724856 30 int _score;
Psy1990 8:32825d724856 31
Psy1990 8:32825d724856 32
Psy1990 8:32825d724856 33 };
Psy1990 8:32825d724856 34 #endif