Li Ruofan 201199450

Dependencies:   mbed

Committer:
DannyLee
Date:
Sat May 23 19:01:15 2020 +0000
Revision:
0:80a59a49d504
Child:
1:bd7c99a5bd10
The new project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DannyLee 0:80a59a49d504 1 #ifndef SNAKE_H
DannyLee 0:80a59a49d504 2 #define SNAKE_H
DannyLee 0:80a59a49d504 3
DannyLee 0:80a59a49d504 4 #include "mbed.h"
DannyLee 0:80a59a49d504 5 #include "N5110.h"
DannyLee 0:80a59a49d504 6 #include "Gamepad.h"
DannyLee 0:80a59a49d504 7
DannyLee 0:80a59a49d504 8 /*
DannyLee 0:80a59a49d504 9 ELEC2645 Embedded Systems Project
DannyLee 0:80a59a49d504 10 School of Electronic & Electrical Engineering
DannyLee 0:80a59a49d504 11 University of Leeds
DannyLee 0:80a59a49d504 12 Name: Ruofan Li
DannyLee 0:80a59a49d504 13 Username: el17rl
DannyLee 0:80a59a49d504 14 Student ID Number: 201199450
DannyLee 0:80a59a49d504 15 Date: May, 2020
DannyLee 0:80a59a49d504 16 */
DannyLee 0:80a59a49d504 17
DannyLee 0:80a59a49d504 18 /* set position */
DannyLee 0:80a59a49d504 19
DannyLee 0:80a59a49d504 20 struct Body{
DannyLee 0:80a59a49d504 21
DannyLee 0:80a59a49d504 22 char bodyX[5000];
DannyLee 0:80a59a49d504 23 char bodyY[5000];
DannyLee 0:80a59a49d504 24 char _Joystick[5000];
DannyLee 0:80a59a49d504 25
DannyLee 0:80a59a49d504 26 };
DannyLee 0:80a59a49d504 27
DannyLee 0:80a59a49d504 28 struct pos{
DannyLee 0:80a59a49d504 29 int x;
DannyLee 0:80a59a49d504 30 int y;
DannyLee 0:80a59a49d504 31
DannyLee 0:80a59a49d504 32 };
DannyLee 0:80a59a49d504 33
DannyLee 0:80a59a49d504 34 class Snake{
DannyLee 0:80a59a49d504 35
DannyLee 0:80a59a49d504 36
DannyLee 0:80a59a49d504 37 public:
DannyLee 0:80a59a49d504 38
DannyLee 0:80a59a49d504 39
DannyLee 0:80a59a49d504 40
DannyLee 0:80a59a49d504 41 /** Set the initial parameters of the project
DannyLee 0:80a59a49d504 42 */
DannyLee 0:80a59a49d504 43 void init(int _x, int _y, int _L,int _life);
DannyLee 0:80a59a49d504 44
DannyLee 0:80a59a49d504 45 void draw(N5110 &lcd);
DannyLee 0:80a59a49d504 46
DannyLee 0:80a59a49d504 47 void update(Gamepad &pad);
DannyLee 0:80a59a49d504 48
DannyLee 0:80a59a49d504 49 void death(N5110 &lcd);
DannyLee 0:80a59a49d504 50
DannyLee 0:80a59a49d504 51 void produceBody();
DannyLee 0:80a59a49d504 52
DannyLee 0:80a59a49d504 53 void changeDir(Gamepad &pad);
DannyLee 0:80a59a49d504 54
DannyLee 0:80a59a49d504 55 void press(Gamepad &pad);
DannyLee 0:80a59a49d504 56
DannyLee 0:80a59a49d504 57 void WallMeet(N5110 &lcd);
DannyLee 0:80a59a49d504 58
DannyLee 0:80a59a49d504 59 void checkBodyMeet(N5110 &lcd);
DannyLee 0:80a59a49d504 60
DannyLee 0:80a59a49d504 61 bool eatApple();
DannyLee 0:80a59a49d504 62
DannyLee 0:80a59a49d504 63 /** Constructor */
DannyLee 0:80a59a49d504 64 Snake();
DannyLee 0:80a59a49d504 65
DannyLee 0:80a59a49d504 66 /** Destructor */
DannyLee 0:80a59a49d504 67 ~Snake();
DannyLee 0:80a59a49d504 68
DannyLee 0:80a59a49d504 69 int L;
DannyLee 0:80a59a49d504 70
DannyLee 0:80a59a49d504 71 int Life;
DannyLee 0:80a59a49d504 72
DannyLee 0:80a59a49d504 73 void drawApple(N5110 &lcd);
DannyLee 0:80a59a49d504 74
DannyLee 0:80a59a49d504 75 void produceApple();
DannyLee 0:80a59a49d504 76
DannyLee 0:80a59a49d504 77 void initApple();
DannyLee 0:80a59a49d504 78
DannyLee 0:80a59a49d504 79 pos getPos();
DannyLee 0:80a59a49d504 80
DannyLee 0:80a59a49d504 81 private:
DannyLee 0:80a59a49d504 82
DannyLee 0:80a59a49d504 83 int _direction;
DannyLee 0:80a59a49d504 84 int beginX;
DannyLee 0:80a59a49d504 85 int beginY;
DannyLee 0:80a59a49d504 86 int beginL;
DannyLee 0:80a59a49d504 87 Direction d;
DannyLee 0:80a59a49d504 88 };
DannyLee 0:80a59a49d504 89 #endif