pvjc25/du8/main.c
2025-06-11 12:22:15 +02:00

38 lines
1.0 KiB
C

#include <stdio.h>
#include "game.h"
#include "world.h" // *
int main() {
world_init(); // * inicializácia world
GameState game;
int mode = select_game_mode();
init_game(&game, mode);
while (1) {
world_clear(); // * vyčistenie obrazovky
draw_game(&game); // * vykreslenie hracieho poľa
if (check_winner(&game)) {
world_print("\nVyhral hrac %c!\n", game.symbols[game.current_player]); // * výpis
break;
} else if (game.moves_made >= game.board_size * game.board_size) {
world_print("\nRemiza!\n"); // * výpis
break;
}
if (game.mode == 3 && game.current_player == 1) {
computer_move(&game);
} else {
handle_input(&game); // * ovládanie
}
game.current_player = (game.current_player + 1) % game.num_players;
}
world_print("Stlač akúkoľvek klávesu pre ukončenie...\n"); // * výpis
world_read_key(); // * caka na vstup
world_end(); // *
return 0;
}