/*TODO free game ptr*/ game* init_game(uint8_t* board) { game* game_ptr = (game *) malloc(sizeof(game)); game_ptr->score = 0; game_ptr->level = 1; game_ptr->lives = 3; game_ptr->pacman_ptr = init_pacman(); game_ptr->board = board; game_ptr->fruit_set = 0; return game_ptr; }
void run_pacman_app(WINDOW* wnd) { static int already_run = 0; if (already_run) { wprintf(&shell_wnd, "PacMan already running.\n\n"); return; } already_run = 1; init_pacman(wnd, 4); }
/*Ici les fantomes accélèrent de plus en plus * et le but est de tenir le plus longtemps * sans se faire dévorer*/ void survivor(int level, config *cfg) { if(level>=NB_LEVEL) return; int selection, counter=SDL_GetTicks(), tmp=counter, elapsed; SAVE_ENABLE=0; play_menu(level); Pacman pac; Fantome ftm[NB_MAX_GHOSTS]; score_message *msg_list = NULL; Input in; init_pacman(&pac, cfg); init_level(); init_blocks(); load_level(level); pac_restart(&pac); pac.nb_lives=1; init_ghosts(ftm, cfg); memset(&in,0,sizeof(in)); DELAY = 40; while(pac.nb_lives && POINTS) { elapsed = SDL_GetTicks()-tmp; if(elapsed > 10000) { //On accélere les fantomes speed_up(ftm, 1); tmp=SDL_GetTicks(); } UpdateEvents(&in); if(in.quit) //Si clique sur croix { delete(&pac, ftm); exit(EXIT_SUCCESS); } while(in.key[SDLK_ESCAPE]) { selection=game_menu(); if(selection==0) in.key[SDLK_ESCAPE]=0; else if(selection==2) //Retour menu principal { delete(&pac, ftm); return; } } jouer(&pac, ftm, in, cfg, level, &msg_list); } counter = SDL_GetTicks() - counter; fprintf(stderr, "Wouaw tu as tenu %d ms!\n", counter); if(pacmanIsHuman(cfg)) draw_result("data/survivor.txt", counter); delete(&pac, ftm); }
/*Permet de jouer un seul niveau * choisi dans la liste des niveaux * disponibles*/ void one_level(int level, config *cfg) { if(level>=NB_LEVEL) return; int selection; SAVE_ENABLE=0; play_menu(level); Pacman pac; Fantome ftm[NB_MAX_GHOSTS]; score_message *msg_list = NULL; Input in; init_pacman(&pac, cfg); init_level(); init_blocks(); load_level(level); pac_restart(&pac); init_ghosts(ftm, cfg); memset(&in,0,sizeof(in)); DELAY = 40-level; while(POINTS) //Tant que l'on a pas mangé toutes les pac-gommes { UpdateEvents(&in); if(in.quit) //Si clique sur croix { delete(&pac, ftm); exit(EXIT_SUCCESS); } while(in.key[SDLK_ESCAPE]) { selection=game_menu(); if(selection==0) in.key[SDLK_ESCAPE]=0; else if(selection==2) //Retour menu principal { delete(&pac, ftm); return; } } if (in.key[SDLK_w]) POINTS=0; //cheat code for winning!! else if (in.key[SDLK_l] || !(pac.nb_lives)) //cheat code for loosing!! { lost_menu(); delete(&pac, ftm); if(pacmanIsHuman(cfg)) draw_result("data/results.txt", pac.score); return; } jouer(&pac, ftm, in, cfg, level, &msg_list); } win_menu(); if(pacmanIsHuman(cfg)) draw_result("data/results.txt", pac.score); delete(&pac, ftm); }
void pacman_func(int argc, char *argv) { if (argc > 7) init_pacman(shell_window, atoi(argv+7)); }
/*Permet de jouer tout les niveaux * à la suite*/ void campagne(config *cfg, int cmp_level) { int selection=0, level; SAVE_ENABLE=1; Pacman pac; Fantome ftm[NB_MAX_GHOSTS]; score_message *msg_list = NULL; Input in; init_pacman(&pac, cfg); init_blocks(); memset(&in,0,sizeof(in)); while(cmp_level < CAMPAGNE_LEVEL) { level=0; while(strcmp(LEVEL_FILE[level], CAMPAGNE[cmp_level]) && level < NB_LEVEL) { level++; } DELAY = 40-cmp_level; play_menu(cmp_level); init_level(); load_level(level); pac_restart(&pac); init_ghosts(ftm, cfg); while(POINTS) //Tant que l'on a pas mangé toutes les pac-gommes { UpdateEvents(&in); if(in.quit) //Si clique sur croix { delete(&pac, ftm); exit(EXIT_SUCCESS); } while(in.key[SDLK_ESCAPE]) { selection=game_menu(); if(selection==0) in.key[SDLK_ESCAPE]=0; else if(selection==1) save_game(cmp_level); else if(selection==2) //Retour menu principal { delete(&pac, ftm); return; } } if (in.key[SDLK_w]) { in.key[SDLK_w]=0; POINTS=0; //cheat code for winning!! } else if (in.key[SDLK_l] || !(pac.nb_lives)) //cheat code for loosing!! { lost_menu(); draw_result("data/results.txt", pac.score); delete(&pac, ftm); return; } jouer(&pac, ftm, in, cfg, cmp_level, &msg_list); } cmp_level++; win_menu(); } draw_result("data/results.txt", pac.score); delete(&pac, ftm); }
int pacmanCommand(char* param1, char* param2) { wprintf(&shell_wnd, "Pacman Executing\n"); init_pacman(&pacMan_wnd,4); return 1; }