Snake game snake library

Committer:
1012754868
Date:
Sun Apr 28 05:49:11 2019 +0000
Revision:
10:f63560a7e7ed
Parent:
9:e023c11f7737
update the death music

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 10:f63560a7e7ed 27 void drawsnake(N5110 &lcd, Gamepad &pad);
1012754868 8:721a8dca7a25 28 void snakemov(Gamepad &pad);
1012754868 10:f63560a7e7ed 29 int dead(N5110 &lcd, Gamepad &pad);
1012754868 9:e023c11f7737 30 void eat(Gamepad &pad);
1012754868 10:f63560a7e7ed 31 void check_WallCollision(N5110 &lcd, Gamepad &pad);
1012754868 10:f63560a7e7ed 32 void check_TailCollision(N5110 &lcd, Gamepad &pad);
1012754868 8:721a8dca7a25 33 void drawscore(N5110 &lcd);
1012754868 9:e023c11f7737 34 void Tone_1(Gamepad &pad);
1012754868 10:f63560a7e7ed 35 void game_music(Gamepad &pad);
Nefos 0:2eb4d7e86e2f 36 int _length;
Nefos 2:5e04e34a3b66 37 int live;
Nefos 4:c74ec3f409f9 38 float waitTime;
1012754868 8:721a8dca7a25 39 float waitExpect;
1012754868 8:721a8dca7a25 40 int _speed;
1012754868 8:721a8dca7a25 41 int Highest_score;
Nefos 0:2eb4d7e86e2f 42
Nefos 1:93a4cb86f100 43
Nefos 0:2eb4d7e86e2f 44
Nefos 6:cc8d2088f490 45 /************************Private Vars************************/
Nefos 0:2eb4d7e86e2f 46 private:
Nefos 6:cc8d2088f490 47
Nefos 0:2eb4d7e86e2f 48 int _direction;
1012754868 8:721a8dca7a25 49 int initx;
1012754868 8:721a8dca7a25 50 int inity;
1012754868 8:721a8dca7a25 51 int initl;
Nefos 0:2eb4d7e86e2f 52 int x;
Nefos 0:2eb4d7e86e2f 53 Direction d;
Nefos 3:b24ef00836c5 54 Food _food;
Nefos 0:2eb4d7e86e2f 55
Nefos 0:2eb4d7e86e2f 56
Nefos 6:cc8d2088f490 57 };
Nefos 0:2eb4d7e86e2f 58
Nefos 0:2eb4d7e86e2f 59 #endif