Snake game snake library

Committer:
Nefos
Date:
Thu May 04 12:01:04 2017 +0000
Revision:
0:2eb4d7e86e2f
Child:
1:93a4cb86f100
Highly buggy version, something went wrong with the snake movement, have to fix it now..;

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 0:2eb4d7e86e2f 8 #include "GameEngine.h"
Nefos 0:2eb4d7e86e2f 9 #include <deque>
Nefos 0:2eb4d7e86e2f 10
Nefos 0:2eb4d7e86e2f 11 struct snakePart{
Nefos 0:2eb4d7e86e2f 12 char _x[4000];
Nefos 0:2eb4d7e86e2f 13 char _y[4000];
Nefos 0:2eb4d7e86e2f 14 char _dir[4000];
Nefos 0:2eb4d7e86e2f 15
Nefos 0:2eb4d7e86e2f 16 };
Nefos 0:2eb4d7e86e2f 17
Nefos 0:2eb4d7e86e2f 18
Nefos 0:2eb4d7e86e2f 19 class Snake
Nefos 0:2eb4d7e86e2f 20 {
Nefos 0:2eb4d7e86e2f 21 public:
Nefos 0:2eb4d7e86e2f 22
Nefos 0:2eb4d7e86e2f 23 Snake();
Nefos 0:2eb4d7e86e2f 24 ~Snake();
Nefos 0:2eb4d7e86e2f 25 void init(int x, int y, int lenght);
Nefos 0:2eb4d7e86e2f 26 void draw(N5110 &lcd);
Nefos 0:2eb4d7e86e2f 27 void update(Gamepad &pad);
Nefos 0:2eb4d7e86e2f 28 snakePart add_point(int x, int y);
Nefos 0:2eb4d7e86e2f 29 void get_length();
Nefos 0:2eb4d7e86e2f 30 int _length;
Nefos 0:2eb4d7e86e2f 31
Nefos 0:2eb4d7e86e2f 32
Nefos 0:2eb4d7e86e2f 33
Nefos 0:2eb4d7e86e2f 34 private:
Nefos 0:2eb4d7e86e2f 35 //deque<snakePart> snek;
Nefos 0:2eb4d7e86e2f 36
Nefos 0:2eb4d7e86e2f 37 int _speed;
Nefos 0:2eb4d7e86e2f 38 int _direction;
Nefos 0:2eb4d7e86e2f 39 int counter;
Nefos 0:2eb4d7e86e2f 40 //int _snakeX[4000];
Nefos 0:2eb4d7e86e2f 41 //int _snakeY[4000];
Nefos 0:2eb4d7e86e2f 42 //int _snakeDir[4000];
Nefos 0:2eb4d7e86e2f 43 int x;
Nefos 0:2eb4d7e86e2f 44 Direction d;
Nefos 0:2eb4d7e86e2f 45
Nefos 0:2eb4d7e86e2f 46
Nefos 0:2eb4d7e86e2f 47 };
Nefos 0:2eb4d7e86e2f 48
Nefos 0:2eb4d7e86e2f 49 #endif