-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnake.h
57 lines (44 loc) · 1.03 KB
/
Snake.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* File: InputHandler.h
* Author: Jeff Longo
* Comments: Snake game implementation
*/
// Header guard, prevents including this file more than once
#ifndef SNAKE_H
#define SNAKE_H
#include <ArduinoSTL.h>
#include <deque>
#include "Cube.h"
#include "InputHandler.h"
#include "Direction.h"
class Snake
{
public:
// Initializes the snake
Snake();
// Polls for a start button press then initializes runtime variables
void start();
// Executes one game tick
void update();
// Resets the game state
void reset();
// Checks if the snake is alive
bool isDead() { return dead; }
private:
// Structure to hold a 3D coordinate point
struct Coord { byte x, y, z; };
// Initializes runtime variables
void init();
// Executes game logic
void logic();
// Generates a new food piece
void generateFood();
Cube cube;
bool m[4][4][4];
std::deque<Coord> snake;
Coord food;
InputHandler io;
bool dead;
int frameTime;
};
#endif // SNAKE_H