Snake game snake library

Committer:
1012754868
Date:
Fri Apr 26 04:46:54 2019 +0000
Revision:
8:721a8dca7a25
Parent:
7:a2f426a37e60
Child:
9:e023c11f7737
Snake library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nefos 0:2eb4d7e86e2f 1 #ifndef SNAKE_H
Nefos 0:2eb4d7e86e2f 2 #define SNAKE_H
Nefos 0:2eb4d7e86e2f 3
Nefos 0:2eb4d7e86e2f 4
Nefos 0:2eb4d7e86e2f 5 #include "mbed.h"
Nefos 0:2eb4d7e86e2f 6 #include "N5110.h"
Nefos 0:2eb4d7e86e2f 7 #include "Gamepad.h"
Nefos 2:5e04e34a3b66 8 #include "Food.h"
Nefos 6:cc8d2088f490 9 /************************Structs************************/
Nefos 0:2eb4d7e86e2f 10 struct snakePart{
Nefos 0:2eb4d7e86e2f 11 char _x[4000];
Nefos 0:2eb4d7e86e2f 12 char _y[4000];
1012754868 8:721a8dca7a25 13 char _dirc[4000];
Nefos 0:2eb4d7e86e2f 14
Nefos 0:2eb4d7e86e2f 15 };
Nefos 6:cc8d2088f490 16
Nefos 6:cc8d2088f490 17 /************************Class Def************************/
Nefos 0:2eb4d7e86e2f 18
Nefos 6:cc8d2088f490 19 class Snake{
Nefos 6:cc8d2088f490 20
Nefos 6:cc8d2088f490 21 /************************Public Vars************************/
Nefos 0:2eb4d7e86e2f 22 public:
Nefos 0:2eb4d7e86e2f 23
Nefos 0:2eb4d7e86e2f 24 Snake();
Nefos 0:2eb4d7e86e2f 25 ~Snake();
Nefos 3:b24ef00836c5 26 void init(int x, int y, int lenght,int _live);
1012754868 8:721a8dca7a25 27 void drawsnake(N5110 &lcd);
1012754868 8:721a8dca7a25 28 void snakemov(Gamepad &pad);
1012754868 8:721a8dca7a25 29 void dead(N5110 &lcd);
1012754868 8:721a8dca7a25 30 void eat();
1012754868 8:721a8dca7a25 31 void check_WallCollision(N5110 &lcd);
1012754868 8:721a8dca7a25 32 void check_TailCollision(N5110 &lcd);
1012754868 8:721a8dca7a25 33 void drawscore(N5110 &lcd);
Nefos 0:2eb4d7e86e2f 34 int _length;
Nefos 2:5e04e34a3b66 35 int live;
Nefos 4:c74ec3f409f9 36 float waitTime;
1012754868 8:721a8dca7a25 37 float waitExpect;
1012754868 8:721a8dca7a25 38 int _speed;
1012754868 8:721a8dca7a25 39 int Highest_score;
Nefos 0:2eb4d7e86e2f 40
Nefos 1:93a4cb86f100 41
Nefos 0:2eb4d7e86e2f 42
Nefos 6:cc8d2088f490 43 /************************Private Vars************************/
Nefos 0:2eb4d7e86e2f 44 private:
Nefos 6:cc8d2088f490 45
Nefos 0:2eb4d7e86e2f 46 int _direction;
1012754868 8:721a8dca7a25 47 int initx;
1012754868 8:721a8dca7a25 48 int inity;
1012754868 8:721a8dca7a25 49 int initl;
Nefos 0:2eb4d7e86e2f 50 int x;
Nefos 0:2eb4d7e86e2f 51 Direction d;
Nefos 3:b24ef00836c5 52 Food _food;
Nefos 0:2eb4d7e86e2f 53
Nefos 0:2eb4d7e86e2f 54
Nefos 6:cc8d2088f490 55 };
Nefos 0:2eb4d7e86e2f 56
Nefos 0:2eb4d7e86e2f 57 #endif