int main() { t_board board; SDL_Surface *ecran; char *levelname; if (SDL_Init(SDL_INIT_VIDEO) == -1) { xwrite(2, "SDL_INIT Error\n", 15); exit(EXIT_FAILURE); } if ((levelname = getlevel()) != NULL) get_map(&board, levelname); else return (1); board.mobs = create_mobs(&board); init_player(&board.player.ix, &board.player.iy, &board); board.player.nb_life = 3; ecran = xSDL_SetVideoMode(board.size * 30 , board.h * 30, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); SDL_WM_SetCaption("Epikong", NULL); board.ecran = ecran; aff_board(&board, ecran); play_the_game(&board); return (0); }
int main() { int choice, last_game; srand(time(0)); // Seed the randomizer with the current time. if(get_player_data() == -1) // Try to read player data from file. register_new_player(); // If there is no data, register a new player. while(choice != 7) { printf("-=[ Game of Chance Menu ]=-\n"); printf("1 - Play the Pick a Number game\n"); printf("2 - Play the No Match Dealer game\n"); printf("3 - Play the Find the Ace game\n"); printf("4 - View current high score\n"); printf("5 - Change your user name\n"); printf("6 - Reset your account at 100 credits\n"); printf("7 - Quit\n"); printf("[Name: %s]\n", player.name); printf("[You have %u credits] -> ", player.credits); scanf("%d", &choice); if((choice < 1) || (choice > 7)) printf("\n[!!] The number %d is an invalid selection.\n\n", choice); else if (choice < 4) { // Otherwise, choice was a game of some sort. if(choice != last_game) { // If the function ptr isn't set if(choice == 1) // then point it at the selected game player.current_game = pick_a_number; else if(choice == 2) player.current_game = dealer_no_match; else player.current_game = find_the_ace; last_game = choice; // and set last_game. } play_the_game(); // Play the game. } else if (choice == 4) show_highscore(); else if (choice == 5) { printf("\nChange user name\n"); printf("Enter your new name: "); input_name(); printf("Your name has been changed.\n\n"); } else if (choice == 6) { printf("\nYour account has been reset with 100 credits.\n\n"); player.credits = 100; } } update_player_data(); printf("\nThanks for playing! Bye.\n"); }
int sub_function(int fd) { char *line; int gnl_check; t_rows **begin; if (!(begin = (t_rows**)malloc(sizeof(t_rows*)))) return (-1); if ((gnl_check = get_next_line(fd, &line)) == -1) return (-1); if (get_first_row(begin, line) == -1) return (-1); while ((gnl_check = get_next_line(fd, &line))) { if (fd == 0 && (ft_isspace(line[0]) || line[0] == 0)) break ; if (gnl_check == -1 || add_rows(begin, line) == -1) return (-1); } free(line); ft_screenclr(); play_the_game(begin); return (0); }