summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2022-11-21 15:29:28 -0800
committerKai Stevenson <kai@kaistevenson.com>2022-11-21 15:29:28 -0800
commit779dc08629330a78f6ee1d646a41198985c92f8d (patch)
tree6b5e088ee2aa835fd860db9b514e4a22ed373456
parent1d93b6696cbcf268d0e035e3837a3188f001e3bc (diff)
user input, some game logic
-rw-r--r--.gitignore1
-rw-r--r--ttt.c15
2 files changed, 14 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cba7efc
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+a.out
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;
}
}