-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaze.h
86 lines (71 loc) · 1.77 KB
/
maze.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
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
#ifndef MAZE
#define MAZE
#define WINDOW_SIZE 840
#define TILE_SIZE 20
#define MAP_SIZE 20
// 0 0 0 0 1 1 1 1
#define COMPLETELY_BLOCKED 15
// 0 0 0 0 0 0 0 1
#define UP 1
// 0 0 0 0 0 0 1 0
#define LEFT 2
// 0 0 0 0 0 1 0 0
#define DOWN 4
// 0 0 0 0 1 0 0 0
#define RIGHT 8
// 0 0 0 0 0 0 0 0
#define NONE 0
typedef struct Tile {
int x;
int y;
int distance;
int unreachable;
char blocks;
char connections;
// 0 0 0 0 0 0 0 0
// ^ ^ ^ ^ ^ ^ ^ ^
// | | | | | | | -> connected up
// | | | | | | ---> connected left
// | | | | | -----> connected down
// | | | | -------> connected right
// | | | ---------> unused
// | | -----------> unused
// | -------------> unused
// ---------------> unused
} Tile;
typedef struct Map {
unsigned int tileCount;
int width;
int height;
Tile * tiles;
} Map;
typedef enum Event
{
NOTHING = 0,
QUIT = 1,
REDO = 2
} Event;
typedef enum Direction
{
NORTH = 0,
WEST = 1,
SOUTH = 3,
EAST = 4,
NO_DIRECTION = 5
} Direction;
extern int countDeadends(Map * map);
extern void debugRenderPuzzle(Map * map, int * visited, int x, int y);
extern void debugRenderCursor(int cursorX, int cursorY, int r, int b, int g);
extern void startRender();
extern void endRender();
extern void renderMap(Map * map);
extern void delay(int ms);
extern int accessableTiles(Map * map);
extern Tile * randomTile(Map * map);
extern Tile * randomUnvisitedTile(Map * map);
extern Direction randomNeighbor(Map * map, Tile * tile, Tile ** neighborTile);
extern Direction randomUnvisitedNeighbor(Map * map, Tile * tile, int * visited, Tile ** neighborTile);
extern Direction randomVisitedNeighbor(Map * map, Tile * tile, int * visited, Tile ** neighborTile);
// Path finding
extern Tile * distanceFrom(Map * map, int x, int y);
#endif