Terminal game of Minesweeper, implemented in C with ncurses.
{#} | Time | Hash | Subject | Author | # | (+) | (-) | GPG? |
---|---|---|---|---|---|---|---|---|
12 | 12 Sep 2020 16:19 | 9e98a79 | Create game loop and page structure | Josh Stockin | 1 | 31 | 0 | G |
1 | #include <ncurses.h> |
2 | |
3 | #include "../state.h" |
4 | |
5 | #include "text.h" |
6 | #include "title.h" |
7 | #include "winsize.h" |
8 | |
9 | |
10 | int draw(game_state *state, int ch) { |
11 | clear(); |
12 | draw_winsize(); |
13 | int ret = 0; |
14 | switch (state->page) { |
15 | case Title: { |
16 | ret = draw_title_screen(state, ch); |
17 | break; |
18 | } |
19 | default: |
20 | return 1; |
21 | } |
22 | refresh(); |
23 | return ret; |
24 | } |
25 | |
26 | void draw_loop(game_state *state) { |
27 | int ch = 0; |
28 | while ((ch = getch())) { |
29 | if (draw(state, ch)) break; |
30 | } |
31 | } |
32 |