| 1 | #include <ncurses.h> |
| 2 |
|
| 3 | #include "../game/game.h" |
| 4 | #include "../state.h" |
| 5 | #include "pages.h" |
| 6 | #include "text.h" |
| 7 |
|
| 8 | int draw_game(game_state *state, int ch) { |
| 9 | if (ch == 'q' || ch == 'Q') { |
| 10 | state->page = Title; |
| 11 | state->page_selection = 0; |
| 12 | return draw_title_screen(state, 0); |
| 13 | } |
| 14 | game(state, ch); |
| 15 | game_board *board = state->board; |
| 16 | for (int cell = 0; cell < board->width * board->height; cell++) { |
| 17 | int x = (int)(COLS / 2) - board->width + cell % board->width * 2; |
| 18 | int y = 1 + cell / board->width; |
| 19 | if (board->cells[cell].is_bomb) { |
| 20 | attron(A_BOLD); |
| 21 | mvaddch(y, x, 'X'); |
| 22 | attroff(A_BOLD); |
| 23 | } else if (board->cells[cell].surrounding_bomb_count) { |
| 24 | attron(COLOR_PAIR(board->cells[cell].surrounding_bomb_count)); |
| 25 | mvaddch(y, x, '0' + board->cells[cell].surrounding_bomb_count); |
| 26 | attroff(COLOR_PAIR(board->cells[cell].surrounding_bomb_count)); |
| 27 | } |
| 28 | } |
| 29 | return 0; |
| 30 | } |
| 31 |
|