CSpiel::CSpiel(const int player_team1_1, const int player_team1_2, const int player_team2_1, const int player_team2_2){ CSpiel::m_game_field = NULL; CSpiel::m_field_size_y = DEFAULT_FIELD_SIZE_Y; CSpiel::m_field_size_x = DEFAULT_FIELD_SIZE_X; start_new_game(GAMEMODE_4_COLORS_4_PLAYERS); CSpiel::set_teams(player_team1_1, player_team1_2, player_team2_1, player_team2_2); }
//-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- cGame::cGame() { start_new_game(); m_focus_coluna = -1; m_focus_linha = -1; }
/** Start a new game after users and teams are selected. */ void misc_callback_start_game(void) { #ifdef DEBUG printf("misc_callback_start_game\n"); #endif gint i; GtkToggleButton *radio_load = GTK_TOGGLE_BUTTON(lookup_widget(window.startup, "radiobutton_team_def_load")); GtkToggleButton *radio_names = GTK_TOGGLE_BUTTON(lookup_widget(window.startup, "radiobutton_team_def_names")); GtkToggleButton *checkbutton_randomise_teams = GTK_TOGGLE_BUTTON(lookup_widget(window.startup, "checkbutton_randomise_teams")); stat0 = STATUS_MAIN; /* option_add(&options, "int_opt_load_defs", 1, NULL); */ /* option_add(&options, "int_opt_randomise_teams", 0, NULL); */ if(gtk_toggle_button_get_active(checkbutton_randomise_teams)) opt_set_int("int_opt_randomise_teams", 1); if(gtk_toggle_button_get_active(radio_load)) opt_set_int("int_opt_load_defs", 1); else if(gtk_toggle_button_get_active(radio_names)) opt_set_int("int_opt_load_defs", 2); else opt_set_int("int_opt_load_defs", 0); start_new_game(); window_destroy(&window.startup); file_store_text_in_saves("last_country", country.sid); if(!opt_int("int_opt_calodds")) { for(i=0;i<users->len;i++) user_set_up_team_new_game(&usr(i)); window_create(WINDOW_MAIN); game_gui_show_main(); if(statp != NULL) { debug_action((gchar*)statp); g_free(statp); statp = NULL; } } else { free_users(TRUE); debug_calibrate_betting_odds(opt_int("int_opt_calodds_skilldiffmax"), opt_int("int_opt_calodds_matches")); main_exit_program(EXIT_OK, NULL); } }
void golgotha_app::return_to_game() { if (!g1_map_is_loaded()) { start_new_game(); } else if (main_menu) { hide_main_menu(); } }
/** * type_selection * @widget: widget * @data: callback data * * Description: * handles configuration selection messages **/ static void type_selection (GtkWidget * widget, gpointer data) { gint num = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); properties.selected_config = num; conf_set_configuration (game_config_name (properties.selected_config)); set_game_config (properties.selected_config); start_new_game (); }
void Cpvp::do_wait_time_out_game(mapid_t homeid) { DEBUG_LOG("Cpvp::do_wait_time_out_game(%lu) called", homeid); std::map<mapid_t, Cgame_item>::iterator it = homeid_game_map.find(homeid); if (it == homeid_game_map.end()) { return; } Cgame_item& item = it->second; if (item.userid_set.size() > 1) { start_new_game(item); } else { DEBUG_LOG("Cpvp::do_wait_time_out_game(): userid_set.size() == 1"); } }
void Cpvp::cd_map(mapid_t homeid, uint32_t userid) { DEBUG_LOG("Cpvp::cd_map(homeid = %lu,userid = %u) called", homeid, userid); std::map<mapid_t, Cgame_item>::iterator it; it = homeid_game_map.find(homeid); if (it != homeid_game_map.end()) { Cgame_item& item = it->second; if (item.user_score_map.find(userid) != item.user_score_map.end()) { item.userid_set.insert(userid); std::map<userid_t, stru_user_score_info>::iterator user_it = item.user_score_map.find(userid); if (user_it != item.user_score_map.end()) { DEBUG_LOG("%u is_alive", user_it->first); user_it->second.is_alive = 1; } send_noti_pvp_winner(homeid, 0, 0); home_game_noti_left_time_out out; out.time_out_type = 1; out.left_time = no_entry_timeout; if (item.userid_set.size() == 1) { out.left_time = 0xffffffff; //第一个人一直等待,无超时 item.add_user_time_out_and_start_game_time = 0xffffffff; } else { uint32_t timeout = time(NULL) + no_entry_timeout; item.add_user_time_out_and_start_game_time = timeout; no_entry_time_homeid_map.insert(std::make_pair(timeout, homeid)); } send_msg_to_all_users(&out, homeid, home_game_noti_left_time_cmd); print_userid_sets(homeid); size_t size = item.userid_set.size(); if (size == game_user_count) { start_new_game(item); } else if (size < game_user_count) { if (size < item.user_score_map.size()) { //有人获取了mapid但并没有进入地图 } } else { DEBUG_LOG("Cpvp::cd_map() too many users in userid_set."); } } } }
int main (int argc, char *argv[]) { gchar *game_filename = NULL; gchar *graphics_filename = NULL; gchar *splash_filename = NULL; gchar *music_filename = NULL; gchar *hints_filename = NULL; gtk_init (&argc, &argv); gui_init (); text_init (); graphics_init (); read_config_file (); if (argc >= 6) hints_filename = g_strdup (argv[5]); if (argc >= 5) music_filename = g_strdup (argv[4]); if (argc >= 4) splash_filename = g_strdup (argv[3]); if (argc >= 3) graphics_filename = g_strdup (argv[2]); if (argc >= 2) game_filename = g_strdup (argv[1]); gtk_widget_show_all (Gui.main_window); if (start_new_game (game_filename, graphics_filename, splash_filename, music_filename, hints_filename)) gtk_main (); return 0; }
void handle_menu_choice(eMenu item_hit) { std::string dialogToShow; sf::Event dummyEvent = {sf::Event::KeyPressed}; short i, choice; switch(item_hit) { case eMenu::NONE: break; case eMenu::FILE_OPEN: do_load(); break; case eMenu::FILE_SAVE: do_save(0); break; case eMenu::FILE_SAVE_AS: do_save(1); break; case eMenu::FILE_NEW: if(overall_mode != MODE_STARTUP) { std::string choice = cChoiceDlog("restart-game",{"okay","cancel"}).show(); if(choice == "cancel") return; for(i = 0; i < 6; i++) univ.party[i].main_status = eMainStatus::ABSENT; party_in_memory = false; reload_startup(); overall_mode = MODE_STARTUP; draw_startup(0); } start_new_game(); draw_startup(0); menu_activate(); break; case eMenu::FILE_ABORT: if(overall_mode != MODE_STARTUP) { std::string choice = cChoiceDlog("abort-game",{"okay","cancel"}).show(); if (choice=="cancel") return; reload_startup(); overall_mode = MODE_STARTUP; } party_in_memory = false; draw_startup(0); menu_activate(); break; case eMenu::PREFS: pick_preferences(); break; case eMenu::QUIT: if(overall_mode == MODE_STARTUP) { if(party_in_memory) { std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { fs::path file = nav_put_party(); if(!file.empty()) break; save_party(file, univ); } } All_Done = true; break; } if(overall_mode > MODE_TOWN) { std::string choice = cChoiceDlog("quit-confirm-nosave",{"quit","cancel"}).show(); if(choice == "cancel") return; } else { std::string choice = cChoiceDlog("quit-confirm-save",{"quit","save","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { if(univ.file.empty()) { univ.file = nav_put_party(); if(univ.file.empty()) break; } save_party(univ.file, univ); } } All_Done = true; break; case eMenu::OPTIONS_PC_GRAPHIC: choice = char_select_pc(1,"New graphic for who?"); if(choice < 6) pick_pc_graphic(choice,1,nullptr); draw_terrain(); break; case eMenu::OPTIONS_DELETE_PC: if(!prime_time()) { ASB("Finish what you're doing first."); print_buf(); } else { choice = char_select_pc(1,"Delete who?"); if(choice < 6) { std::string confirm = cChoiceDlog("delete-pc-confirm",{"yes","no"}).show(); if(confirm == "yes") kill_pc(univ.party[choice],eMainStatus::ABSENT); } draw_terrain(); } break; case eMenu::OPTIONS_RENAME_PC: choice = char_select_pc(1,"Rename who?"); if(choice < 6) pick_pc_name(choice,nullptr); put_pc_screen(); put_item_screen(stat_window); break; case eMenu::OPTIONS_NEW_PC: if(!(is_town())) { add_string_to_buf("Add PC: Town mode only."); print_buf(); break; } for(i = 0; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ABSENT) i = 20; if(i == 6) { ASB("Add PC: You already have 6 PCs."); print_buf(); break; } if(univ.town->has_tavern) { give_help(56,0); create_pc(6,nullptr); } else { add_string_to_buf("Add PC: You cannot add new characters in this town. Try in the town you started in.", 2); } print_buf(); put_pc_screen(); put_item_screen(stat_window); break; case eMenu::OPTIONS_JOURNAL: journal(); break; case eMenu::OPTIONS_TALK_NOTES: if(overall_mode == MODE_TALKING) { ASB("Talking notes: Can't read while talking."); print_buf(); return; } talk_notes(); break; case eMenu::OPTIONS_ENCOUNTER_NOTES: adventure_notes(); break; case eMenu::OPTIONS_STATS: if(overall_mode != MODE_STARTUP) print_party_stats(); break; case eMenu::HELP_OUT: dialogToShow = "help-outdoor"; break; case eMenu::HELP_TOWN: dialogToShow = "help-town"; break; case eMenu::HELP_COMBAT: dialogToShow = "help-combat"; break; case eMenu::HELP_BARRIER: dialogToShow = "help-fields"; break; case eMenu::HELP_HINTS: dialogToShow = "help-hints"; break; case eMenu::HELP_SPELLS: dialogToShow = "help-magic"; break; case eMenu::ABOUT: dialogToShow = "about-boe"; break; case eMenu::LIBRARY_MAGE: display_spells(eSkill::MAGE_SPELLS,100,0); break; case eMenu::LIBRARY_PRIEST: display_spells(eSkill::PRIEST_SPELLS,100,0); break; case eMenu::LIBRARY_SKILLS: display_skills(eSkill::INVALID,0); break; case eMenu::LIBRARY_ALCHEMY: // TODO: Create a dedicated dialog for alchemy info display_alchemy(); break; case eMenu::LIBRARY_TIPS: tip_of_day(); break; case eMenu::LIBRARY_INTRO: dialogToShow = "welcome"; break; case eMenu::ACTIONS_ALCHEMY: dummyEvent.key.code = sf::Keyboard::A; dummyEvent.key.shift = true; handle_keystroke(dummyEvent); break; case eMenu::ACTIONS_WAIT: dummyEvent.key.code = sf::Keyboard::W; handle_keystroke(dummyEvent); break; case eMenu::ACTIONS_AUTOMAP: if(!prime_time()) { ASB("Finish what you're doing first."); print_buf(); } else { give_help(62,0); display_map(); } make_cursor_sword(); break; case eMenu::HELP_TOC: if(fs::is_directory(progDir/"doc")) launchURL("file://" + (progDir/"doc/game/Contents.html").string()); else launchURL("https://blades.calref.net/doc/game/Contents.html"); break; case eMenu::ABOUT_MAGE: case eMenu::ABOUT_PRIEST: give_help(209,0); break; case eMenu::ABOUT_MONSTERS: give_help(212,0); break; } if(!dialogToShow.empty()) { cChoiceDlog dlog(dialogToShow); dlog.show(); } }
/** * new_cb * @action: Pointer to action * @data: Callback data * * Description: * Callback for new menu entry * * Returns: **/ static void new_cb (GtkAction * action, gpointer data) { start_new_game (); }
void golgotha_app::receive_event(i4_event * ev) { switch (ev->type()) { case i4_event::DISPLAY_CHANGE: { CAST_PTR(dev, i4_display_change_event_class, ev); if (dev->change==i4_display_change_event_class::SIZE_CHANGE) { get_root_window()->resize(get_display()->width(),get_display()->height()); } } break; case i4_event::DO_COMMAND: { fo_sym.get(); g1_cwin_man->receive_event(ev); char * cmd=((i4_do_command_event_class *)ev)->command; li_symbol * s=li_get_symbol(cmd); if (li_get_fun(s,0)) { li_call(s); } g1_input.receive_event(ev); } break; case i4_event::END_COMMAND: { g1_cwin_man->receive_event(ev); char cmd[200]; sprintf(cmd, "-%s",((i4_do_command_event_class *)ev)->command); li_symbol * s=li_get_symbol(cmd); if (li_get_fun(s,0)) { li_call(cmd); } g1_input.receive_event(ev); } break; case i4_event::USER_MESSAGE: { CAST_PTR(uev,i4_user_message_event_class,ev); switch (uev->sub_type) { case G1_MAIN_MENU: do_main_menu(); break; case G1_NETWORK_MENU: network_menu(); break; case G1_SERVER_MENU: server_menu(); break; case G1_CLIENT_JOINED_MENU: client_wait_menu(); break; case G1_YOU_LOSE: help_screen("youlose_screen", G1_MAIN_MENU); break; case G1_YOU_WIN: { CAST_PTR(fptr,i4_file_open_message_class,uev); win_screen("youwin_screen", fptr->filename); } break; case G1_HELP_SCREEN: help_screen("help_screen", G1_RETURN_TO_GAME); break; case G1_START_HELP_SCREEN: help_screen("help_screen", G1_START_NEW_GAME); break; case G1_PLOT_SCREEN: plot_screen(); break; case G1_START_NEW_GAME: start_new_game(); break; case G1_RETURN_TO_GAME: return_to_game(); break; case G1_SAVEGAME_SAVE: save_savegame(); break; case G1_SAVEGAME_SAVE_OK: save_savegame_ok(uev); //Saving a savegame must not change //the map's filename. break; case G1_SAVEGAME_LOAD_OK: start_saved_game(uev); break; case G1_SAVEGAME_LOAD: open_savegame(); break; case G1_OPTIONS: do_options(); break; case G1_QUIT: quit(); break; case G1_ESCAPE: do_main_menu(); break; case G1_MAP_CHANGED: map_changed(); break; case G1_GET_ROOT_IMAGE: { CAST_PTR(get, g1_get_root_image_event, ev); get->result=display->get_screen(); } break; case G1_REDRAW_LATER: { redraw_later.waiting=i4_F; li_call("redraw_all"); } break; case G1_PLAY_MOVIE: if (g1_map_is_loaded()) { pre_play_save(); if (g1_get_map()->start_movie()) { playing_movie=i4_T; g1_resources.paused=i4_F; } } break; case G1_STOP_MOVIE: { if (playing_movie) { if (g1_map_is_loaded()) { g1_get_map()->stop_movie(); post_play_load(); } playing_movie=i4_F; if (g1_current_controller.get() && g1_current_controller->view.get_view_mode()==G1_CAMERA_MODE) { g1_current_controller->view.suggest_camera_mode(G1_ACTION_MODE); } } } break; case G1_GET_CURRENT_MOVIE: { if (g1_map_is_loaded()) { CAST_PTR(mev, g1_get_current_movie_event, ev); mev->mflow=g1_get_map()->current_movie; } } break; case G1_INTERLACE_PIXEL: { g1_cwin_man->destroy_views(); g1_resources.render_window_expand_mode = R1_COPY_1x1_SCANLINE_SKIP; g1_cwin_man->create_views(); } break; case G1_DOUBLE_PIXEL: { g1_cwin_man->destroy_views(); g1_resources.render_window_expand_mode = R1_COPY_2x2; g1_cwin_man->create_views(); } break; case G1_NORMAL_PIXEL: { g1_cwin_man->destroy_views(); g1_resources.render_window_expand_mode = R1_COPY_1x1; g1_cwin_man->create_views(); } break; } } break; default: i4_application_class::receive_event(ev); } }
main (int argc, char *argv[]) { char inFile[80]; char ans; int ans2; int done = 0; int play_again_flag = 1; int seed = 1; printf ("argc = %d\n", argc); if (argc >= 3) { printf ("argv[1] = %s, argv[2] = %s\n", argv[1], argv[2]); if (!strcmp(argv[1], "-i")) strcpy (inFile, argv[2]); printf ("inFile = %s\n", inFile); inFile_fp = fopen (inFile, "r"); if (inFile_fp == NULL) printf ("failed to open input file - %s\n", inFile); else printf ("reading commands from input file - %s\n", inFile); if (argc == 4) { printf ("argv[3] = %s\n", argv[1]); seed = atoi(argv[3]); printf ("using specified random seed = %d\n", seed); } else { printf ("using default random seed = %d\n", seed); } } else if (argc == 2) { printf ("argv[1] = %s\n", argv[1]); seed = atoi(argv[1]); printf ("using specified random seed = %d\n", seed); } else if (argc == 1) { seed = (((int) time(0)) % 100000) + 2; printf ("using generated random seed = %d\n", seed); } srand(seed); initialize(); introduction(); printf ("Do you wish to skip the detailed reports "); printf ("at the end of each year"); ans = getYesNo(); szR = ans; printf ("Do you want to play"); ans = getYesNo(); if (ans == 'Y') { printf ("okay - let's give the wheel a spin\n\n"); play_again_flag = 1; } else { printf ("ok - see ya round\n"); play_again_flag = 0; } while (play_again_flag) { start_new_game(); done = 0; while (!done) { last_years_results(); if (end_of_game_check()) { done = 1; continue; } feed_the_peasants(); if (starvation_and_unrest()) { done = 1; continue; } if (purchase_land() == 0) { if (sell_land()) { done = 1; continue; } } if (war_with_the_king()) { done = 1; continue; } grain_production(); update_land_tables(); crop_yield_and_losses(); if (war()) { done = 1; continue; } population_changes(); if (harvest_grain()) { done = 1; continue; } update_unrest(); } play_again_flag = play_again(); } exit(0); }
Boolean handle_menu (short item, HMENU) { short choice,i; POINT x = {1001,0},pass_point; Boolean to_return = false; switch (item) { case 1: // File Menu if (in_startup_mode == true) startup_load(); else do_load(); break; case 2: do_save(0); break; case 3: if (in_startup_mode == true) save_file(1); else do_save(1); break; case 4: if (in_startup_mode == false) { choice = FCD(1091,0); if (choice == 1) return false; for (i = 0; i < 6; i++) adven[i].main_status = MAIN_STATUS_ABSENT; party_in_memory = false; reload_startup(); in_startup_mode = true; draw_startup(0); } start_new_game(); draw_startup(0); break; case 6: pick_preferences(); break; case 7: pick_compatibility(); break; case 8: // Quit if (in_startup_mode == true) { to_return = All_Done = true; break; } if (overall_mode > MODE_TOWN) { choice = FCD(1067,0); if (choice == 1) return All_Done; } else { choice = FCD(1066,0); if (choice == 3) break; if (choice == 1) save_file(0); } to_return = All_Done = true; break; // Options menu case 21: choice = char_select_pc(0,0,"New graphic for who?"); if (choice < 6) pick_pc_graphic(choice,1,0); initiate_redraw(); break; case 22: choice = select_pc(0,0); if (choice < 6) pick_pc_name(choice,0); put_pc_screen(); put_item_screen(stat_window,0); break; case 23: if (!(is_town())) { add_string_to_buf("Add PC: Town mode only."); print_buf(); break; } for (i = 0; i < NUM_OF_PCS; i++) if (adven[i].main_status == MAIN_STATUS_ABSENT) i = 20; if (i == INVALID_PC) { ASB("Add PC: You already have 6 PCs."); print_buf(); } if (c_town.town_num == scenario.which_town_start) { give_help(56,0,0); create_pc(6,0); } else { add_string_to_buf("Add PC: You can only make new"); add_string_to_buf(" characters in the town you "); add_string_to_buf(" started in."); } print_buf(); put_pc_screen(); put_item_screen(stat_window,0); break; case 24: if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else { choice = char_select_pc(0,0,"Delete who?"); if (choice < 6) { if ((i = FCD(1053,0)) == 2) adven[choice].kill(0); } initiate_redraw(); } break; case 27: if (overall_mode == MODE_TALKING) { ASB("Talking notes: Can't read while talking."); print_buf(); return to_return; } talk_notes(); break; case 28: adventure_notes(); break; case 29: if (in_startup_mode == false) print_party_stats(); break; // Help menu case 41: FCD(1079,0); break; case 42: FCD(1080,0); break; case 43: FCD(1081,0); break; case 44: FCD(1072,0); break; // magic barriers case 46: FCD(1084,0); break; case 47: FCD(1088,0); break; // Library case 61: display_spells(0,100,0); break; case 62: display_spells(1,100,0); break; case 63: display_skills(100,0); break; case 64: display_help(0,0); break; case 65: tip_of_day(); break; case 67: FCD(986,0); break; // Actions case 81: if (overall_mode != MODE_TOWN) { ASB("Alchemy: In town mode only."); print_buf(); break; } pass_point.x = 1000; pass_point.y = 405; to_return = handle_action(pass_point,(WPARAM) 0,(LPARAM)-1); break; case 82: to_return = handle_action(x,(WPARAM) 0,(LPARAM)-1); break; case 84: if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else { give_help(62,0,0); display_map(); } SetCursor(sword_curs); break; // Mage is 399 case 399: give_help(209,0,0); party.help_received[9] = false; break; // Priest is 499 case 499: give_help(209,0,0); party.help_received[9] = false; break; // Monsters is 599 case 599: give_help(212,0,0); break; case 100: // Index WinHelp(mainPtr,"Blades of Exile.hlp",HELP_CONTENTS,0L); break; case 200: // About FCD(1062,0); break; default: if ((item >= 400) && (item < 500)) { // mage spell if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else handle_menu_spell(item - 400,0); break; } if ((item >= 500) && (item < 600)) { // priest spell if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else handle_menu_spell(item - 500,1); break; } if ((item >= 600) && (item < 700)) { // monster spell display_monst(item - 600,(creature_data_type *) NULL,1); break; } break; } if (in_startup_mode == true) menu_activate(0); else menu_activate(1); return to_return; }
Boolean handle_startup_press(POINT the_point) { short i,scen; long dummy; the_point.x -= ulx; the_point.y -= uly; for (i = 0; i < 5; i++) if (PtInRect(&startup_button[i],the_point) == true) { draw_start_button(i,5); if (play_sounds == true) play_sound(37); else Delay(5,&dummy); draw_start_button(i,0); switch (i) { case 0: startup_load(); break; case 1: draw_startup(0); start_new_game(); draw_startup(0); break; case 2: // Not cross-platform. ShellExecute(NULL, "open", "http://spiderwebforums.ipbhost.com/index.php?/forum/12-blades-of-exile/", NULL, NULL, SW_SHOWNORMAL); draw_startup(0); break; case 3: if (party_in_memory == false) { // check if party is loaded FCD(867,0); //no party loaded error message break; } scen = pick_prefab_scen(); // return a short in scen specifying the chosen scenario if (scen < 0) break; switch (scen) { //put scenario filename in party.scen_name case 0: sprintf(party.scen_name,"valleydy.exs"); break; case 1: sprintf(party.scen_name,"stealth.exs"); break; case 2: sprintf(party.scen_name,"zakhazi.exs"); break; } put_party_in_scen(); //put the party in the scenario and begin the game break; case 4: // intro if (party_in_memory == false) { // check if party is loaded FCD(867,0); //no party loaded error message break; } scen = pick_a_scen(); // return a short to scen specifying the chosen scenario /* if (scen_headers[scen].prog_make_ver[0] >= 2) { => warning if scen = -1 (no scenarios in directory), then it will crash !!! FCD(912,0); break; }*/ if (scen >= 0) { sprintf(party.scen_name,"%s",data_store2[scen].scen_names); //put scenario filename in party.scen_name retrieving it using scen put_party_in_scen(); //put the party in the scenario and begin the game } break; default: Delay(50,&dummy); return true; } } return false; }
int game_loop(){ unsigned redraw = 0; game_rect t; rect_Zero(&t); sprite_sheet = gamespr_create("ski1.bmp"); animation_init(); init_player(); start_new_game(0); while(!mainloop){ ALLEGRO_EVENT e; ALLEGRO_TIMEOUT timeout; int i; al_init_timeout(&timeout, 0.06); bool late = al_wait_for_event_until(g_queue, &e, &timeout); if(late){ switch(e.type){ case ALLEGRO_EVENT_DISPLAY_CLOSE: mainloop = 1; break; case ALLEGRO_EVENT_KEY_UP: player_poll_kbd_up(&e); break; case ALLEGRO_EVENT_KEY_DOWN: player_poll_kbd_dn(&e); break; case ALLEGRO_EVENT_TIMER: /* main clock updates 1/60ms (60FPS LOCK) */ if(e.timer.source == g_timer){ particle_list = particles_clean(particle_list, 0); particles_update(particle_list); player_update_screen(); player_update(&ski_player, &playfield); for(i = 1; i < MAX_SPRITES; i++){ update_enemy(i); } update_enemy_behavior(gobj_list, &playfield); redraw = 1; } /* update for the chronomenter run every 100ms only) */ if( e.timer.source == timer_chrono){ HUD_UpdateChrono(); DMSG("%d", al_get_timer_count(timer_chrono)); } break; } if( redraw == 1 && al_event_queue_is_empty(g_queue)){ redraw = 0; al_clear_to_color(WHITE_COLOR); particles_draw(NULL, particle_list); player_draw(ski_player.object->position.x, ski_player.object->position.y ); for(i = 1; i < MAX_OBJECTS; i++){ int enemy_type = gobj_list[i].type; draw_enemy(enemy_type, i, 0,0, gobj_list[i].position.x, gobj_list[i].position.y, 32,32); } HUD_create_stats_box(); al_flip_display(); } } } HUD_destroy(); unload_spritesheets(); window_deinit(); particle_list = particles_clean(particle_list, PARTICLES_ALL_CLEAN); return EXIT_SUCCESS; }