Fix to the const definition
[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 #include "othello.h"
8
9 int main() {
10 int row = 0, col = 0;
11 int key_pressed = 0;
12 bool exit_condition = false;
13
14 initscr();
15 if (has_colors() == false) {
16 endwin();
17 printf("Votre terminal ne supporte pas les couleurs\n");
18 exit(EXIT_FAILURE);
19 }
20 start_color();
21 getmaxyx(stdscr, row, col);
22 noecho();
23 curs_set(0);
24
25 /* center the board */
26 int center_board_y = row/2 - 23/2;
27 int center_board_x = col/2 - 41/2;
28
29 do {
30 print_board(center_board_y, center_board_x);
31
32 key_pressed = getch();
33 if (key_pressed == 'q') {
34 exit_condition = true;
35 }
36 } while (!exit_condition);
37
38 endwin();
39
40 exit(EXIT_SUCCESS);
41 }