-
Notifications
You must be signed in to change notification settings - Fork 1
/
defines.h
129 lines (112 loc) · 3.27 KB
/
defines.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef _DEFINES_H
#define _DEFINES_H 1
/**
* @def REVEAL_SURROUNDING
* @brief Compile with "reveal surrounding" feature
* @details If defined, adds the "reveal surrounding" feature. With this
* feature, adjacent tiles will get revealed if the user is trying to reveal:
* - An already revealed tile
* - With adjacent bombs
* - With all bombs flagged
* Comment this line if you don't want this feature.
*/
#define REVEAL_SURROUNDING
/**
* @def USE_ARROWS
* @brief Enable arrow key support.
* @details If you compile the program with `USE_ARROWS`, you will be able to
* navigate with the arrows.
*/
#define USE_COLOR
/**
* @def USE_COLOR
* @brief Compile with color enabled.
* @details If you compile the program with `USE_COLOR` and your terminal
* supports it, it will render the tiles with color.
*/
#define USE_MOUSE
/**
* @enum color_ids
* @brief Color ids used for the curses color pairs.
*/
enum color_ids {
COL_NORM = 0, /* White */
COL_1 = 1, /* 1 bombs adjacent */
COL_2 = 2, /* 2 bombs adjacent */
COL_3 = 3, /* 3 bombs adjacent */
COL_4 = 4, /* 4 bombs adjacent */
COL_5 = 5, /* 5 bombs adjacent */
COL_6 = 6, /* 6 bombs adjacent */
COL_7 = 7, /* 7 bombs adjacent */
COL_8 = 8, /* 8 bombs adjacent */
COL_9 = 9, /* 9 bombs adjacent */
COL_FLAG = 10, /* Red */
COL_BOMB = 11, /* Red */
COL_UNK = 12, /* Gray */
};
/**
* @name Color macros
* Will only work if color is enabled and supported.
*/
#define SET_COL(col) \
if (use_color) { \
attron(COLOR_PAIR(col)); \
}
#define RESET_COL(col) \
if (use_color) { \
attroff(COLOR_PAIR(col)); \
}
#define BOLD_ON() \
if (use_color) { \
attron(A_BOLD); \
}
#define BOLD_OFF() \
if (use_color) { \
attroff(A_BOLD); \
}
#define DEFAULT_W 50 /**< @brief Default width */
#define DEFAULT_H 20 /**< @brief Default height */
#define MIN_W 10 /**< @brief Minimum width */
#define MIN_H 10 /**< @brief Minimum height */
/**
* @def BOMB_MARGIN
* @brief Bombs won't spawn in a 3x3 grid from the starting reveal
*/
#define BOMB_MARGIN 3
#define DEFAULT_DIFFICULTY 30 /**< @brief 1-100% */
#define MIN_BOMBS 5 /**< @brief Minimum ammount of bombs */
#define MAX_BOMBS 60 /**< @brief Maximum ammount of bombs */
/**
* @enum tile_flags
* @brief For tile_t.flags
*/
enum tile_flags {
FLAG_NONE = 0x0, /* Tile is hidden and not flagged */
FLAG_CLEARED = 0x1, /* Tile is revealed */
FLAG_FLAGGED = 0x2, /* Tile is flagged */
};
/**
* @enum playing_flags
* @brief For Game.playing
*/
enum playing_flags {
PLAYING_FALSE = 0x0, /* Just started a game. Grid empty. */
PLAYING_TRUE = 0x1, /* Playing a game. Grid filled. */
PLAYING_CLEAR = 0x2, /* Just initialized the empty grid. Fill with bombs */
};
/**
* @enum tile_chars
* @brief Characters for the tiles
*/
enum tile_chars {
CH_UNKN = '.', /* Not revealed tile */
CH_BACK = ' ', /* Empty tile with no bombs adjacent */
CH_BOMB = '@', /* Revealed tile with bomb */
CH_FLAG = 'F', /* Flagged hidden tile */
};
/**
* @def KEY_CTRLC
* @brief Needed for getch()
*/
#define KEY_CTRLC 3
#endif /* _DEFINES_H */