Index

ncurses-minesweeper / 82ddf89

Terminal game of Minesweeper, implemented in C with ncurses.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
1812 Sep 2020 23:2382ddf89Colors; base game state and game renderingJosh Stockin171G

Blob @ ncurses-minesweeper / src / draw / draw.c

text/plain868 bytesdownload raw
1#include <ncurses.h>
2
3#include "../state.h"
4
5#include "pages.h"
6#include "text.h"
7#include "winsize.h"
8
9
10int draw(game_state *state, int ch) {
11 clear();
12 int ret = 0;
13 attron(COLOR_PAIR(5));
14 switch (state->page) {
15 case Title: {
16 ret = draw_title_screen(state, ch);
17 break;
18 }
19 case Game: {
20 ret = draw_game(state, ch);
21 break;
22 }
23 case Options: {
24 ret = draw_options_screen(state, ch);
25 break;
26 }
27 case Help: {
28 ret = draw_help_screen(state, ch);
29 break;
30 }
31 default:
32 return 1;
33 }
34 draw_winsize();
35 attroff(COLOR_PAIR(5));
36 refresh();
37 return ret;
38}
39
40void draw_loop(game_state *state) {
41 int ch = 0;
42 while ((ch = getch())) {
43 if (draw(state, ch)) break;
44 }
45}
46