TP 13 exo2: Add the code structure and some basic displaying routines for the tic...
[TD_C.git] / TP_13 / exo2 / src / main.c
diff --git a/TP_13/exo2/src/main.c b/TP_13/exo2/src/main.c
new file mode 100644 (file)
index 0000000..fcd3bcc
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <ncurses.h>
+
+#include "display.h"
+
+int main() {
+    int row, col;
+
+    initscr();
+    getmaxyx(stdscr,row,col);
+    noecho();
+    curs_set(0);
+
+    /* center base coordinates for the board */
+    const int base_y = row/2 - 4;
+    const int base_x = col/2 - 7;
+
+    print_board(base_y, base_x);
+
+    print_x(base_y, base_x + 1);
+    print_o(base_y, base_x + 6);
+    print_o(base_y, base_x + 11);
+    print_o(base_y + 3, base_x + 1);
+    print_o(base_y + 6, base_x + 1);
+    print_o(base_y + 3, base_x + 6);
+    print_x(base_y + 3, base_x + 11);
+    print_x(base_y + 6, base_x + 6);
+    print_x(base_y + 6, base_x + 11);
+    
+    refresh();
+
+    while (getch() != 'q');
+
+    endwin();
+
+    exit(EXIT_SUCCESS);
+}