diff options
| -rwxr-xr-x[-rw-r--r--] | Tic Tac Toe.c | 16 | ||||
| -rw-r--r-- | readme.md | 9 | ||||
| -rwxr-xr-x | ttt | bin | 8836 -> 16984 bytes |
3 files changed, 20 insertions, 5 deletions
diff --git a/Tic Tac Toe.c b/Tic Tac Toe.c index 2506cd0..e927068 100644..100755 --- a/Tic Tac Toe.c +++ b/Tic Tac Toe.c | |||
| @@ -2,15 +2,20 @@ | |||
| 2 | #include<stdlib.h> | 2 | #include<stdlib.h> |
| 3 | #include<ctype.h> | 3 | #include<ctype.h> |
| 4 | #include<string.h> | 4 | #include<string.h> |
| 5 | |||
| 5 | char check_board(char[10],char[10]); | 6 | char check_board(char[10],char[10]); |
| 6 | int print_board(char[10]); | 7 | int print_board(char[10]); |
| 7 | int check_tied(char[10]); | 8 | int check_tied(char[10]); |
| 9 | |||
| 8 | // 0|1|2 | 10 | // 0|1|2 |
| 9 | // - - - | 11 | // - - - |
| 10 | // 3|4|5 | 12 | // 3|4|5 |
| 11 | // - - - | 13 | // - - - |
| 12 | // 6|7|8 | 14 | // 6|7|8 |
| 13 | 15 | ||
| 16 | //TODO: Add timer of 2 second? | ||
| 17 | //TODO: Add more stuff to do than TTT | ||
| 18 | |||
| 14 | int main(void){ | 19 | int main(void){ |
| 15 | char board[10] = " "; | 20 | char board[10] = " "; |
| 16 | char vis_board[10] = "123456789"; | 21 | char vis_board[10] = "123456789"; |
| @@ -19,7 +24,7 @@ int main(void){ | |||
| 19 | int block; | 24 | int block; |
| 20 | char gg[10]; | 25 | char gg[10]; |
| 21 | char *ptr; | 26 | char *ptr; |
| 22 | 27 | ||
| 23 | //main game loop | 28 | //main game loop |
| 24 | while (1){ | 29 | while (1){ |
| 25 | 30 | ||
| @@ -51,10 +56,10 @@ int main(void){ | |||
| 51 | } | 56 | } |
| 52 | break; | 57 | break; |
| 53 | } | 58 | } |
| 54 | 59 | ||
| 55 | } | 60 | } |
| 56 | 61 | ||
| 57 | 62 | ||
| 58 | //checks if win condition met or tie | 63 | //checks if win condition met or tie |
| 59 | if (check_board(vis_board,board) == 1){ | 64 | if (check_board(vis_board,board) == 1){ |
| 60 | if (x_turn){ | 65 | if (x_turn){ |
| @@ -71,7 +76,7 @@ int main(void){ | |||
| 71 | printf("\nGame tied\n"); | 76 | printf("\nGame tied\n"); |
| 72 | break; | 77 | break; |
| 73 | } | 78 | } |
| 74 | 79 | ||
| 75 | x_turn = !x_turn; | 80 | x_turn = !x_turn; |
| 76 | o_turn = !o_turn; | 81 | o_turn = !o_turn; |
| 77 | 82 | ||
| @@ -82,6 +87,7 @@ int main(void){ | |||
| 82 | } | 87 | } |
| 83 | 88 | ||
| 84 | int print_board(char board[10]){ | 89 | int print_board(char board[10]){ |
| 90 | printf("\n"); | ||
| 85 | for (int i = 0; i < strlen(board); ++i){ | 91 | for (int i = 0; i < strlen(board); ++i){ |
| 86 | printf("%c",board[i]); | 92 | printf("%c",board[i]); |
| 87 | if (i != 2 && i != 5 && i != 8){ | 93 | if (i != 2 && i != 5 && i != 8){ |
| @@ -0,0 +1,9 @@ | |||
| 1 | # Tic Tac Toe | ||
| 2 | |||
| 3 | The game is tic tac toe. | ||
| 4 | |||
| 5 | I made this in first year engineering as a bored project since my C programming class wasn't challenging enough and I just wanted to do something more fun than what was asked. | ||
| 6 | |||
| 7 | # Plans | ||
| 8 | [ ] Maybe I will add a timer to each turn to up the difficulty | ||
| 9 | [ ] a way to clear the terminal so it doen't get too flooded | ||
| Binary files differ | |||
