1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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(" HAND: %d ", hand);
if ( i == 6) printw(" POSITION: %d ", board[cursorPosX][cursorPosY]);
attroff(A_BOLD | COLOR_PAIR(4));
printw("\n");
}
}
|