Index

ncurses-minesweeper / 14fa750

Terminal game of Minesweeper, implemented in C with ncurses.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
1913 Sep 2020 14:2371d76abAdd majority of game logic, renderingJosh Stockin140G

Blob @ ncurses-minesweeper / src / main.c

text/plain1016 bytesdownload raw
1#include <ncurses.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5#include "colors.h"
6#include "draw/draw.h"
7#include "state.h"
8
9int main(void) {
10 printf("ncurses-minesweeper Copyright (c) Joshua 'joshuas3' Stockin 2020\n");
11 printf("<https://joshstock.in>\n");
12 printf("<https://github.com/JoshuaS3/ncurses-minesweeper>\n");
13
14 game_state *state = calloc(1, sizeof(game_state));
15 state->page = Title;
16 state->page_selection = 0;
17 game_board *board = calloc(1, sizeof(game_board));
18 state->board = board;
19 state->board->width = 30;
20 state->board->height = 16;
21 state->board->mine_count = 99;
22
23 initscr();
24 noecho();
25 cbreak();
26
27 if (!has_colors()) {
28 printf("Your terminal doesn't support color.\n");
29 endwin();
30 return 1;
31 }
32 init_colorpairs();
33 curs_set(0);
34
35 draw(state, 0); // draw initial window
36 draw_loop(state); // enter control input loop
37
38 endwin();
39
40 free(board->cells);
41 free(board);
42 free(state);
43
44 return 0;
45}
46