1 | #ifndef STATE_H |
2 | #define STATE_H |
3 |
|
4 | #include "stdint.h" |
5 |
|
6 | typedef enum DrawPage { Title, Game, Options, Help } DrawPage; |
7 | typedef enum GameStatus { Playing, Done, Kaboom } GameStatus; |
8 |
|
9 | typedef struct game_board_cell { |
10 | uint8_t is_bomb : 1; |
11 | uint8_t flagged : 1; |
12 | uint8_t opened : 1; |
13 | uint8_t surrounding_bomb_count : 3; // maximum possible is 8, only need 3 bits |
14 | } game_board_cell; |
15 |
|
16 | typedef struct game_board { |
17 | uint8_t width; |
18 | uint8_t height; |
19 | uint16_t current_cell; // (x,y) | x = current_cell % width, y = current_cell / width |
20 | uint8_t mine_count; |
21 | uint8_t mines_left; |
22 | GameStatus status; |
23 | game_board_cell *cells; // heap allocated, size = width * height, position in array determines position on board |
24 | } game_board; |
25 |
|
26 | typedef struct game_state { |
27 | DrawPage page; |
28 | uint8_t page_selection; // character/token that determines what part of the screen (button/input) is selected |
29 | game_board *board; |
30 | } game_state; |
31 |
|
32 | #endif |
33 |
|