ead55ef8004ee9c018a5ace3fbb72c82cb1d5cb5
[Project_algorithmic_C.git] / src / main.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <ncurses.h>
5
6 #include "ui.h"
7
8 int main() {
9 int row = 0, col = 0;
10 int key_pressed = 0;
11 bool exit_condition = false;
12
13 initscr();
14 if (has_colors() == false) {
15 endwin();
16 printf("Votre terminal ne supporte pas les couleurs\n");
17 exit(EXIT_FAILURE);
18 }
19 start_color();
20 getmaxyx(stdscr, row, col);
21 noecho();
22 curs_set(0);
23
24 /* center the board */
25 int center_board_y = row/2 - 23/2;
26 int center_board_x = col/2 - 40/2;
27
28 do {
29 print_board(center_board_y, center_board_x);
30
31 key_pressed = getch();
32 if (key_pressed == 'q') {
33 exit_condition = true;
34 }
35 } while (!exit_condition);
36
37 endwin();
38
39 exit(EXIT_SUCCESS);
40 }