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 10:51:30 2020 +0000
Revision:
9:25597bc0cecc
Parent:
8:32825d724856
Child:
10:3e37b58e8600
Managed to get the snake and apple placement working! Still working on movement :(

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 9:25597bc0cecc 15
Psy1990 9:25597bc0cecc 16 enum eDirection {STOP = 0, LEFT, RIGHT, UP, DOWN};
Psy1990 9:25597bc0cecc 17 eDirection dir;
Psy1990 9:25597bc0cecc 18 void init(int _x, int _y, int _speed, int _score);
Psy1990 8:32825d724856 19 void draw(N5110 &lcd);
Psy1990 9:25597bc0cecc 20 void control(Gamepad &pad, N5110 &lcd);
Psy1990 8:32825d724856 21 void read_input(Gamepad &pad);
Psy1990 8:32825d724856 22 void update(Direction d,float mag);
Psy1990 8:32825d724856 23 void add_score();
Psy1990 8:32825d724856 24 int get_score();
Psy1990 8:32825d724856 25 Vector2D get_pos();
Psy1990 8:32825d724856 26 Vector2D get_Direction();
Psy1990 8:32825d724856 27
Psy1990 8:32825d724856 28 private:
Psy1990 8:32825d724856 29
Psy1990 8:32825d724856 30 int _x;
Psy1990 8:32825d724856 31 int _y;
Psy1990 8:32825d724856 32 int _speed;
Psy1990 8:32825d724856 33 int _score;
Psy1990 8:32825d724856 34
Psy1990 8:32825d724856 35
Psy1990 8:32825d724856 36 };
Psy1990 8:32825d724856 37 #endif