diff options
Diffstat (limited to 'board.c')
| -rw-r--r-- | board.c | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -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"); + } +} |