From 1b1a63e78c3acbeac2951d52ccab4a37cde3e4eb Mon Sep 17 00:00:00 2001 From: st529yr Date: Tue, 14 May 2024 21:51:38 +0200 Subject: [PATCH] funguje --- final/makefile.c | 80 ------------------------------------------------ 1 file changed, 80 deletions(-) delete mode 100644 final/makefile.c diff --git a/final/makefile.c b/final/makefile.c deleted file mode 100644 index a343b75..0000000 --- a/final/makefile.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include "world.h" - -#define WIDTH 11 -#define HEIGHT 11 - -typedef enum {EMPTY, CROSS, CIRCLE} Cell; - -Cell board[HEIGHT][WIDTH] = {EMPTY}; - -void draw_board() { - clear_world(); - for (int y = 0; y < HEIGHT; ++y) { - for (int x = 0; x < WIDTH; ++x) { - int world_x = x * 2 + 1; - int world_y = y * 2 + 1; - if (board[y][x] == CROSS) { - draw_character('X', world_x, world_y); - } else if (board[y][x] == CIRCLE) { - draw_character('O', world_x, world_y); - } - } - } - refresh_world(); -} - -int check_win(Cell player) { - // Check rows - for (int y = 0; y < HEIGHT; ++y) { - int count = 0; - for (int x = 0; x < WIDTH; ++x) { - if (board[y][x] == player) { - count++; - } else { - count = 0; - } - if (count == 5) return 1; - } - } - // Check columns - for (int x = 0; x < WIDTH; ++x) { - int count = 0; - for (int y = 0; y < HEIGHT; ++y) { - if (board[y][x] == player) { - count++; - } else { - count = 0; - } - if (count == 5) return 1; - } - } - // TODO: Implement diagonal checks - return 0; -} - -int main() { - init_world(2 * WIDTH + 1, 2 * HEIGHT + 1); - draw_board(); - int turn = 0; - while (1) { - int x, y; - printf("Player %d's turn. Enter coordinates (x y): ", turn % 2 + 1); - scanf("%d %d", &x, &y); - if (x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT && board[y][x] == EMPTY) { - board[y][x] = (turn % 2 == 0) ? CROSS : CIRCLE; - draw_board(); - if (check_win(board[y][x])) { - printf("Player %d wins!\n", turn % 2 + 1); - break; - } - turn++; - } else { - printf("Invalid move. Try again.\n"); - } - } - close_world(); - return 0; -} -