void play_game(void){ while(TRUE){ draw_tictactoe(); int m[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; bool_t player = FALSE; bool_t won = FALSE; while ((won = game_won(&m)) == FALSE && game_finish(&m) == FALSE){ // uint8_t pos = get_field_from_uart(&m); uint8_t pos = get_from_console(player); uint8_t x = pos % 3; uint8_t y = pos / 3; if(m[pos] == 0){ draw_tictactoe_field(x, y, player); m[pos] = player + 1; player = (player + 1) % 2; } else{ printf("Field is already selected!\n"); } } if(won == TRUE){ draw_won_player((player + 1) % 2); } } }
int main (int argc, char *argv[]) { int bounces, role, most, tickets; initSystemPaths (argv[0]); /* Inicializar l18n */ setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, get_l10n_path ()); textdomain (PACKAGE); setup (); do { if (game_intro () == GAME_QUIT) break; if (game_loop (&bounces, &role, &most, &tickets) == GAME_QUIT) break; if (game_finish (bounces, role, most, tickets) == GAME_QUIT) break; } while (1 == 0); SDL_Quit (); return EXIT_SUCCESS; }
void error(const char *msg) { game_finish(); perror(msg); exit(0); }