diff options
| -rw-r--r-- | console.c | 39 | ||||
| -rw-r--r-- | console.h | 11 |
2 files changed, 24 insertions, 26 deletions
@@ -7,65 +7,66 @@ void draw_board(int board[8][8]) { printf(" A B C D E F G H\n"); - int tileColor = 1; + int tileColor = 0; for(int r = 0; r < 8; r++) { tileColor = !tileColor; - char* line = calloc(2 + (8 * 10), sizeof(char)); + char* line = calloc(2 + (8 * 16) + 8, sizeof(char)); line[0] = '8' - r; line[1] = ' '; for(int c = 0; c < 8; c++) { tileColor = !tileColor; - strcat(line, tileColor == 0 ? ANSI_COLOR_RED : ANSI_COLOR_RESET); + strcat(line, tileColor == 0 ? COLOR_CHESS_WHITE : COLOR_CHESS_BLACK); if(board[c][r] <= 6) { switch(board[c][r]) { case 0: - strcat(line, "# "); + strcat(line, " "); break; case pawn: - strcat(line, "P "); + strcat(line, "P"); break; case knight: - strcat(line, "N "); + strcat(line, "N"); break; case bishop: - strcat(line, "B "); + strcat(line, "B"); break; case rook: - strcat(line, "R "); + strcat(line, "R"); break; case queen: - strcat(line, "Q "); + strcat(line, "Q"); break; case king: - strcat(line, "K "); + strcat(line, "K"); break; } } else { switch(board[c][r] - 6) { case pawn: - strcat(line, "p "); + strcat(line, "p"); break; case knight: - strcat(line, "n "); + strcat(line, "n"); break; case bishop: - strcat(line, "b "); + strcat(line, "b"); break; case rook: - strcat(line, "r "); + strcat(line, "r"); break; case queen: - strcat(line, "q "); + strcat(line, "q"); break; case king: - strcat(line, "k "); + strcat(line, "k"); break; } } + strcat(line, COLOR_RESET " "); } printf(line); - printf("\n" ANSI_COLOR_RESET); + printf("\n" COLOR_RESET); free(line); } } @@ -96,9 +97,9 @@ void clear_screen() { } void warn_user(char* message) { clear_screen(); - printf("\n"); + printf("\n" COLOR_WARN); printf(message); - printf("\nPress any key to continue...\n"); + printf(COLOR_RESET "\nPress any key to continue...\n"); while(getchar() != '\n'); getchar(); } @@ -1,12 +1,9 @@ #ifndef CONSOLE #define CONSOLE -#define ANSI_COLOR_RED "\x1b[31m" -#define ANSI_COLOR_GREEN "\x1b[32m" -#define ANSI_COLOR_YELLOW "\x1b[33m" -#define ANSI_COLOR_BLUE "\x1b[34m" -#define ANSI_COLOR_MAGENTA "\x1b[35m" -#define ANSI_COLOR_CYAN "\x1b[36m" -#define ANSI_COLOR_RESET "\x1b[0m" +#define COLOR_CHESS_WHITE "\033[1;93;107m" +#define COLOR_CHESS_BLACK "\033[1;93;100m" +#define COLOR_WARN "\033[5;31;49m" +#define COLOR_RESET "\033[0m" void draw_board(int board[8][8]); vector_t user_input_pos(); |
