forked from jasoncoon/LightAppliance
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMaze.h
More file actions
106 lines (79 loc) · 2.12 KB
/
Copy pathMaze.h
File metadata and controls
106 lines (79 loc) · 2.12 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef Maze_H
#define Maze_H
#include "SmartMatrix_32x32.h"
#include "IRremote.h"
class Maze{
private:
enum Directions {
None = 0,
Up = 1,
Down = 2,
Left = 4,
Right = 8,
};
struct Point{
int x;
int y;
static Point New(int x, int y) {
Point point;
point.x = x;
point.y = y;
return point;
}
Point Move(Directions direction) {
switch (direction)
{
case Up:
return New(x, y - 1);
case Down:
return New(x, y + 1);
case Left:
return New(x - 1, y);
case Right:
return New(x + 1, y);
}
}
static Directions Opposite(Directions direction) {
switch (direction) {
case Up:
return Down;
case Down:
return Up;
case Left:
return Right;
case Right:
return Left;
}
}
};
SmartMatrix *matrix;
IRrecv *irReceiver;
static const int width = 16;
static const int height = 16;
int imageWidth = width * 2;
int imageHeight = height * 2;
Directions grid[width][height];
unsigned long lastInput = 0;
Point point;
Point start;
Point end;
Point player;
Point cells[256];
int cellCount = 0;
int highestCellCount = 0;
int algorithm = 0;
int algorithmCount = 2;
Directions directions[4] = { Up, Down, Left, Right };
Point createPoint(int x, int y);
int chooseIndex(int max);
void removeCell(int index);
void shuffleDirections();
int generateMaze(bool animate, boolean(*checkForTermination)());
unsigned long handleInput();
void draw();
int directionsCount(Directions directions);
public:
void runPattern(SmartMatrix matrixRef, IRrecv irReceiverRef, boolean(*checkForTermination)());
void runGame(SmartMatrix matrixRef, IRrecv irReceiverRef);
};
#endif