Implement the othello board printing
[Project_algorithmic_C.git] / src / main.c
diff --git a/src/main.c b/src/main.c
new file mode 100644 (file)
index 0000000..ead55ef
--- /dev/null
@@ -0,0 +1,40 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ncurses.h>
+
+#include "ui.h"
+
+int main() {
+    int row = 0, col = 0;
+    int key_pressed = 0;
+    bool exit_condition = false;
+
+    initscr();
+    if (has_colors() == false) {
+        endwin();
+        printf("Votre terminal ne supporte pas les couleurs\n");
+        exit(EXIT_FAILURE);
+    }
+    start_color();
+    getmaxyx(stdscr, row, col);
+    noecho();
+    curs_set(0);
+
+    /* center the board */
+    int center_board_y = row/2 - 23/2;
+    int center_board_x = col/2 - 40/2;
+
+    do {
+        print_board(center_board_y, center_board_x);
+
+        key_pressed = getch();
+        if (key_pressed == 'q') {
+            exit_condition = true;
+        }
+    } while (!exit_condition);
+
+    endwin();
+
+    exit(EXIT_SUCCESS);
+}