forked from adafruit/Mini-LED-Gamer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnake.h
More file actions
27 lines (24 loc) · 638 Bytes
/
Snake.h
File metadata and controls
27 lines (24 loc) · 638 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "Arduino.h"
class Snake {
private:
uint8_t foodX; //(0-7)
uint8_t foodY; //(0-15)
uint16_t snakeLength;
int8_t snakeHeadX;
int8_t snakeHeadY;
int8_t snakeHeadDX;
int8_t snakeHeadDY;
uint8_t snakeBoard[16][8];
uint8_t activeSnakeBoard[16];
unsigned long lastSnakeMoveTime;
bool allowToChangeDirection;
void placeFood();
bool moveSnake(); // return true if move is valid
void gameOver();
public:
bool gameRunning;
void init();
void run();
void changeDirection(int8_t dx, int8_t dy); // should not run twice
uint8_t* getActiveBoard();
};