From 779dc08629330a78f6ee1d646a41198985c92f8d Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Mon, 21 Nov 2022 15:29:28 -0800 Subject: user input, some game logic --- ttt.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'ttt.c') diff --git a/ttt.c b/ttt.c index 3701d9a..dd7907f 100644 --- a/ttt.c +++ b/ttt.c @@ -78,6 +78,16 @@ int check_win(int boardState[3][3]) { } return 0; } +int is_full(int boardState[3][3]) { + //if all squares full, return 1 + //else return 0 + +} +int is_drawn(int boardState[3][3]) { + //checks if board is full and if no win is on the board + //returns 1 if so, else 0 + +} int* user_input_pos() { int* ip = malloc(2 * sizeof(int)); printf("Enter X coordinate"); @@ -86,20 +96,21 @@ int* user_input_pos() { scanf("%d", &ip[1]); return ip; } -void clr_scr() +void clear_screen() { system("@cls||clear"); } int main() { int board[3][3] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; while(1) { - clr_scr(); + clear_screen(); draw_board(board); int* tl = user_input_pos(); board[tl[0] - 1][3 - tl[1]] = 1; free(tl); if(check_win(board) != 0) { printf("Someone won!"); + printf('\n'); break; } } -- cgit v1.3.1