/*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); }
/*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); }
dword scene_imgkey(dword * selidx) { win_menu_predraw_data prev; t_win_menuitem item[16]; dword i, index; memcpy(&prev, &g_predraw, sizeof(win_menu_predraw_data)); STRCPY_S(item[0].name, _("上一张图")); STRCPY_S(item[1].name, _("下一张图")); STRCPY_S(item[2].name, _("缩放模式")); STRCPY_S(item[3].name, _("缩小图片")); STRCPY_S(item[4].name, _("放大图片")); STRCPY_S(item[5].name, _("左旋90度")); STRCPY_S(item[6].name, _("右旋90度")); STRCPY_S(item[7].name, _(" 信息栏")); STRCPY_S(item[8].name, _("显示信息")); STRCPY_S(item[9].name, _("退出浏览")); STRCPY_S(item[10].name, _("缩放引擎")); STRCPY_S(item[11].name, _("幻灯播放")); STRCPY_S(item[12].name, _("上")); STRCPY_S(item[13].name, _("下")); STRCPY_S(item[14].name, _("左")); STRCPY_S(item[15].name, _("右")); g_predraw.max_item_len = win_get_max_length(item, NELEMS(item)); for (i = 0; i < NELEMS(item); i++) { item[i].width = g_predraw.max_item_len; item[i].selected = false; item[i].icolor = config.menutextcolor; item[i].selicolor = config.selicolor; item[i].selrcolor = config.menubcolor; item[i].selbcolor = config.selbcolor; item[i].data = NULL; } if (DISP_FONTSIZE >= 14) g_predraw.item_count = 12; else g_predraw.item_count = NELEMS(item); g_predraw.x = 240; g_predraw.y = 123; g_predraw.left = g_predraw.x - DISP_FONTSIZE * g_predraw.max_item_len / 2; g_predraw.upper = g_predraw.y - DISP_FONTSIZE * g_predraw.item_count / 2; g_predraw.linespace = 0; while ((index = win_menu(g_predraw.left, g_predraw.upper, g_predraw.max_item_len, g_predraw.item_count, item, g_predraw.item_count, 0, g_predraw.linespace, config.usedyncolor ? get_bgcolor_by_time() : config. menubcolor, true, scene_imgkey_predraw, NULL, scene_imgkey_menucb)) != INVALID); memcpy(&g_predraw, &prev, sizeof(win_menu_predraw_data)); return 0; }