From b84ed1c00abc55df56ffc3588163b6732ad3f0d1 Mon Sep 17 00:00:00 2001 From: KaffeeMaus Date: Fri, 26 Jan 2024 12:03:22 +0100 Subject: [PATCH] added a function to print the game board --- src/main/c/Georg/tictactoe.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/c/Georg/tictactoe.c b/src/main/c/Georg/tictactoe.c index 85a0fec..7242d8a 100644 --- a/src/main/c/Georg/tictactoe.c +++ b/src/main/c/Georg/tictactoe.c @@ -4,6 +4,8 @@ #include "tictactoe.h" +void printBoard(); + struct ticTacToe GAME; struct command COMMANDS[MAX_COMMANDS] = { @@ -114,6 +116,31 @@ int startMenu( int code ){ return 0; } +void printBoard(){ + for( int i = 0; i < BORAD_SIZE*4+1; i++ ){ + printf("-"); + } + printf("\n"); + + for (int i = 0; i < 3; ++i) { + printf("| "); + for (int j = 0; j < 3; ++j) { + if( GAME.board[i][j] == true ) + printf( "X" ); + else + printf ( " " ); + + printf(" | "); + } + printf( "\n" ); + } + + for( int i = 0; i < BORAD_SIZE*4+1; i++ ){ + printf("-"); + } + printf("\n"); +} + int startGame( int code ){ if( code == -1 ){ // command test return 1;