summaryrefslogtreecommitdiffstats
path: root/board.c
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-07-15 06:46:24 +0100
committersumuel <samuel@yakubos.org>2026-07-15 06:46:24 +0100
commitf29f867a18ee82d6c79900420b6a6d5f66a75f18 (patch)
tree900a0cf9f59f2485e1eb0c190f7c16ef5082babb /board.c
init
Diffstat (limited to 'board.c')
-rw-r--r--board.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/board.c b/board.c
new file mode 100644
index 0000000..a4faad3
--- /dev/null
+++ b/board.c
@@ -0,0 +1,49 @@
+#include <ncurses.h>
+#include "board.h"
+#include "input.h"
+int cursorPosX = 4;
+int cursorPosY = 3;
+
+/* Create the board as a 2d array */
+char board[8][8] = {
+ {'r','n','b','q','k','b','n','r'},
+ {'p','p','p','p','p','p','p','p'},
+ {' ',' ',' ',' ',' ',' ',' ',' '},
+ {' ',' ',' ',' ',' ',' ',' ',' '},
+ {' ',' ',' ',' ',' ',' ',' ',' '},
+ {' ',' ',' ',' ',' ',' ',' ',' '},
+ {'P','P','P','P','P','P','P','P'},
+ {'R','N','B','Q','K','B','N','R'},
+};
+
+void PrintBoard(char board[8][8]){
+ for (int i=0; i<8;i++){
+ for (int j=0; j<8;j++){
+
+ if ( i == cursorPosX && j == cursorPosY )
+ {
+ attron(COLOR_PAIR(3));
+ printw(" %c ", board[i][j]);
+ attroff(COLOR_PAIR(3));
+ }
+ else if ((i + j) & 1) /* Make all the even positions white */
+ {
+ attron(COLOR_PAIR(1));
+ printw(" %c ", board[i][j]);
+ attroff(COLOR_PAIR(1));
+ }
+ else
+ {
+ attron(COLOR_PAIR(2));
+ printw(" %c ", board[i][j]);
+ attroff(COLOR_PAIR(2));
+ }
+
+ }
+ attron(A_BOLD | COLOR_PAIR(4));
+ if ( i == 1) printw(" BLACK ");
+ if ( i == 6) printw(" WHITE ");
+ attroff(A_BOLD | COLOR_PAIR(4));
+ printw("\n");
+ }
+}