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
|
#include <ncurses.h>
#include <stdlib.h>
#include "board.h"
#include "input.h"
int main() {
int ch;
initscr(); /* Start curses mode */
if(has_colors() == FALSE)
{ endwin();
printf("Your terminal does not support colour\n");
exit(1);
}
start_color(); /* Start color */
noecho();
curs_set(0);
keypad(stdscr, TRUE);
/* End of ncurses init nonsense */
/* Don't use black it will mess with the background colour */
init_color(COLOR_RED, 556, 388, 176);
init_color(COLOR_WHITE, 820, 840, 880);
init_pair(1, COLOR_RED, COLOR_WHITE);
init_pair(2, COLOR_WHITE, COLOR_RED);
init_pair(3, COLOR_YELLOW, COLOR_MAGENTA);
init_pair(4, COLOR_CYAN, COLOR_BLACK);
while (turns < 1000){
refresh(); /* Print it on to the real screen */
char *player;
player = (turns & 1) ? "BLACK" : "WHITE";
printw("Here is the board:\n");
PrintBoard(board); /* Print out the chess board */
printw("Turn No. %d (%s)", turns, player);
ch = getch(); /* Wait for user input */
InputBoard(board, ch);
clear();
}
endwin(); /* End curses mode */
return 0;
}
|