int menu_load(SDL_Surface* destination, game **p_game){ *p_game = game_load("./res/scripts/save_1.xml"); if(*p_game==NULL){ return 0; } return 1; }
static bool execute(const config& cache_config, savegame::load_game_metadata& data) { if(savegame::get_saves_list().empty()) { gui2::show_transient_message(_("No Saved Games"), _("There are no save files to load")); return false; } return game_load(cache_config, data).show(); }
void load(char *appPath, char *resPath, long handle) { #ifdef MOD_TEST test_load(appPath, resPath, handle); #else benc_load(appPath, resPath, handle); robk_load(appPath, resPath, handle); vinh_load(appPath, resPath, handle); game_load(appPath, resPath, handle); #endif }
game_status state_main_menu(SDL_Surface *screen, game* p_game) { bool done=false; image* main_title; main_title = image_load("./res/images/main_title.png"); SDL_Rect srcrect = {0,0,160,144}; SDL_Rect dstrect = set_rect(0,0,SCREEN_HEIGHT,SCREEN_WIDTH); int next_state=STAY; while (!done) { //events SDL_Event event; while (SDL_PollEvent(&event)) { switch ( event.type ) { case SDL_QUIT: done = true; break; default: break; } } image_draw(main_title, get_backbuffer_surface(), 0, 0); SDL_SoftStretch(get_backbuffer_surface(), &srcrect, screen, &dstrect); SDL_Flip(screen); if(next_state == STAY)next_state = menu_main(screen, p_game); else if(next_state!=QUIT){ switch(next_state){ case LOAD: menu_load(screen, &p_game); next_state = state_in_game(screen, p_game); break; case 1: p_game = game_load("./res/scripts/state.xml"); next_state = state_in_game(screen, p_game); break; default: break; } } else if(next_state==QUIT)done=true; } image_free(main_title); return QUIT; }
void parse_ini (int argc, char * argv[], gameType * game) { /* Decide on action to take on startup */ if (argc == 1) { /* No parameters */ sysMessage(1, game); } else if (!strcmp(argv[1], "new") && (argc > 2) && (argc <= 5)) { /* Start new game */ parse_setup(argc, argv, game); } else if (!strcmp(argv[1], "load") && (argc == 3)) { /* Load a game */ game_load(argv[2], game); play(game); } else { /* Wrong parameters */ sysMessage(11, game); } }
int main(int argc, char *argv[]) { bool inhibit_loadfade = false; bool error = false; bool freshstart; SetLogFilename("debug.txt"); if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { staterr("ack, sdl_init failed: %s.", SDL_GetError()); return 1; } atexit(SDL_Quit); // start up inputs first thing because settings_load may remap them input_init(); // load settings, or at least get the defaults, // so we know the initial screen resolution. settings_load(); if (Graphics::init(settings->resolution)) { staterr("Failed to initialize graphics."); return 1; } if (font_init()) { staterr("Failed to load font."); return 1; } //speed_test(); //return 1; #ifdef CONFIG_DATA_EXTRACTOR if (!settings->files_extracted) { if (extract_main()) { Graphics::close(); font_close(); return 0; } else { settings->files_extracted = true; settings_save(); } } #endif if (check_data_exists()) { return 1; } Graphics::ShowLoadingScreen(); if (sound_init()) { fatal("Failed to initialize sound."); return 1; } if (trig_init()) { fatal("Failed trig module init."); return 1; } if (tsc_init()) { fatal("Failed to initialize script engine."); return 1; } if (textbox.Init()) { fatal("Failed to initialize textboxes."); return 1; } if (Carets::init()) { fatal("Failed to initialize carets."); return 1; } if (game.init()) return 1; game.setmode(GM_NORMAL); // set null stage just to have something to do while we go to intro game.switchstage.mapno = 0; //#define REPLAY #ifdef REPLAY game.switchstage.mapno = START_REPLAY; //Replay::set_ffwd(6000); //Replay::set_stopat(3500); game.switchstage.param = 1; #else //game.switchstage.mapno = LOAD_GAME; //game.pause(GP_OPTIONS); if (settings->skip_intro && file_exists(GetProfileName(settings->last_save_slot))) game.switchstage.mapno = LOAD_GAME; else game.setmode(GM_INTRO); #endif // for debug if (game.paused) { game.switchstage.mapno = 0; game.switchstage.eventonentry = 0; } if (game.switchstage.mapno == LOAD_GAME) inhibit_loadfade = true; game.running = true; freshstart = true; stat("Entering main loop..."); #ifdef __SDLSHIM__ set_console_visible(false); #endif //speed_test(); //return 1; while(game.running) { // SSS/SPS persists across stage transitions until explicitly // stopped, or you die & reload. It seems a bit risky to me, // but that's the spec. if (game.switchstage.mapno >= MAPNO_SPECIALS) { StopLoopSounds(); } // enter next stage, whatever it may be if (game.switchstage.mapno == LOAD_GAME || \ game.switchstage.mapno == LOAD_GAME_FROM_MENU) { if (game.switchstage.mapno == LOAD_GAME_FROM_MENU) freshstart = true; stat("= Loading game ="); if (game_load(settings->last_save_slot)) { fatal("savefile error"); goto ingame_error; } Replay::OnGameStarting(); if (!inhibit_loadfade) fade.Start(FADE_IN, FADE_CENTER); else inhibit_loadfade = false; } else if (game.switchstage.mapno == START_REPLAY) { stat(">> beginning replay '%s'", GetReplayName(game.switchstage.param)); StopScripts(); if (Replay::begin_playback(GetReplayName(game.switchstage.param))) { fatal("error starting playback"); goto ingame_error; } } else { if (game.switchstage.mapno == NEW_GAME || \ game.switchstage.mapno == NEW_GAME_FROM_MENU) { bool show_intro = (game.switchstage.mapno == NEW_GAME_FROM_MENU); InitNewGame(show_intro); } // slide weapon bar on first intro to Start Point if (game.switchstage.mapno == STAGE_START_POINT && \ game.switchstage.eventonentry == 91) { freshstart = true; } // switch maps if (load_stage(game.switchstage.mapno)) goto ingame_error; player->x = (game.switchstage.playerx * TILE_W) << CSF; player->y = (game.switchstage.playery * TILE_H) << CSF; } // start the level if (game.initlevel()) return 1; if (freshstart) weapon_introslide(); gameloop(); game.stageboss.OnMapExit(); freshstart = false; } shutdown: ; Replay::close(); game.close(); Carets::close(); Graphics::close(); input_close(); font_close(); sound_close(); tsc_close(); textbox.Deinit(); return error; ingame_error: ; stat(""); stat(" ************************************************"); stat(" * An in-game error occurred. Game shutting down."); stat(" ************************************************"); error = true; goto shutdown; }
int main(){ //variaveis que tem alguma coisa a ver com o jogados, como exp recebida e level int game_status = 0, option = 0, school = 0; //--------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------- //Variaveis internas relacionadas as bibliotecas usadas e erros do jogo em si. int status_allegro = 0, tecla = 0; //A variavel teclado tem 5 estados /* 0 - Neutro 1 - Tecla para cima 2 - Tecla para Baixo 3 - Tecla para Direita 4 - Tecla para Esquerda */ //iniciando o Allegro e todos as suas bibliotecas e funções usadas. al_init(); al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); al_install_keyboard(); //Iniciando o jogo. display = al_create_display(SCREEN_W, SCREEN_H); background = al_load_bitmap("img/background.jpg"); start_menu_img = al_load_bitmap("img/start_screen.jpg"); font_text = al_load_font("font/font.ttf", 50, 0); timer = al_create_timer(0.1); tcont = al_create_timer(1.0); sections_event = al_create_event_queue(); al_set_window_title(display, "M.I.P. - Matemática, Português e Inglês"); al_start_timer(timer); al_start_timer(tcont); //Qualquer valor que seja colocado apos a imagem, ira interferir na sua posição em relação a tela. fadeout(7, SCREEN_W, SCREEN_H, display); al_draw_bitmap(background, 0,0,0); al_flip_display(); //Verificando erros no allegro e suas bibliotecas. status_allegro = check_allegro(background, start_menu_img, sections_event, display, font_text, timer, tcont); if(status_allegro == -1){ close_game(background, start_menu_img, sections_event, display, timer, tcont); return 0; } al_register_event_source(sections_event, al_get_keyboard_event_source()); al_register_event_source(sections_event, al_get_display_event_source(display)); //--------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------- //menu_background(); fadeout(1, SCREEN_W, SCREEN_H, display); al_draw_bitmap(start_menu_img, 0,0,0); printf("Menu Principal\n"); //capture_event(); al_flip_display(); al_draw_textf(font_text, al_map_rgb(0, 255, 255), SCREEN_H / 4, SCREEN_W / 4, ALLEGRO_ALIGN_LEFT, "Novo Jogo"); al_draw_textf(font_text, al_map_rgb(0, 255, 255), SCREEN_H / (3.7), SCREEN_W / 3, ALLEGRO_ALIGN_LEFT, "Continuar"); al_draw_textf(font_text, al_map_rgb(0, 255, 255), SCREEN_H / (3.4), SCREEN_W / (2.5), ALLEGRO_ALIGN_LEFT, "Sair do jogo"); al_flip_display(); option = capture_event_queue(SCREEN_H, SCREEN_W, keyboard, display, sections_event, tecla, font_text); if(option == -1){ close_game(background, start_menu_img, sections_event, display, timer, tcont); return 0; } switch(option){ case 0: game_start(); printf("game_start\n"); break; case 1: game_load(); printf("game_load\n"); break; case 2: printf("Finalizando Jogo\n"); close_game(background, start_menu_img, sections_event, display, timer, tcont); return 0; break; } //--------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------- //Apos a escolha entre continuar ou começar novamente o usuário estará na tela de seleção de escolas printf("Selecione a escola\n"); scanf("%d", &school); switch(school){ case 0: open_math(); break; case 1: open_ing(); break; case 2: open_port(); break; } //--------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------- return 0; }
void def_load() { game_load(app_name,1); }
bool run_main(void) { if (in_gameloop) goto loop; // SSS/SPS persists across stage transitions until explicitly // stopped, or you die & reload. It seems a bit risky to me, // but that's the spec. if (game.switchstage.mapno >= MAPNO_SPECIALS) { StopLoopSounds(); } // enter next stage, whatever it may be if (game.switchstage.mapno == LOAD_GAME || \ game.switchstage.mapno == LOAD_GAME_FROM_MENU) { if (game.switchstage.mapno == LOAD_GAME_FROM_MENU) freshstart = true; NX_LOG("= Loading game =\n"); if (game_load(settings->last_save_slot)) { fatal("savefile error"); game.running = false; error = 1; return false; } Replay::OnGameStarting(); if (!inhibit_loadfade) fade.Start(FADE_IN, FADE_CENTER); else inhibit_loadfade = false; } else if (game.switchstage.mapno == START_REPLAY) { NX_LOG(">> beginning replay '%s'\n", GetReplayName(game.switchstage.param)); StopScripts(); if (Replay::begin_playback(GetReplayName(game.switchstage.param))) { fatal("error starting playback"); game.running = false; error = 1; return false; } } else { if (game.switchstage.mapno == NEW_GAME || \ game.switchstage.mapno == NEW_GAME_FROM_MENU) { static bool show_intro = (game.switchstage.mapno == NEW_GAME_FROM_MENU); InitNewGame(show_intro); } // slide weapon bar on first intro to Start Point if (game.switchstage.mapno == STAGE_START_POINT && \ game.switchstage.eventonentry == 91) { freshstart = true; } // switch maps if (load_stage(game.switchstage.mapno)) { game.running = false; error = 1; return false; } player->x = (game.switchstage.playerx * TILE_W) << CSF; player->y = (game.switchstage.playery * TILE_H) << CSF; } // start the level if (game.initlevel()) { game.running = false; error = 1; return false; } if (freshstart) weapon_introslide(); game.switchstage.mapno = -1; loop: in_gameloop = true; if (gameloop()) return true; in_gameloop = false; game.stageboss.OnMapExit(); freshstart = false; }
int main(int argc, char **argv) { cl_options_t cl_options = {0}; dbg_init(); DBG_LOG("Version %s", g_version); ui = &ui_sdlgl; printf("DreamChess %s\n", g_version); parse_options(argc, argv, &ui, &cl_options); config_init(); set_cl_options(&cl_options); if (!ui) { DBG_ERROR("Failed to find a user interface driver"); exit(1); } ui->init(); init_resolution(); while (1) { board_t board; int pgn_slot; option_t *option; if (!(config = ui->config(&pgn_slot))) break; ch_userdir(); option = config_get_option("first_engine"); #ifdef __APPLE__ char temp1[200]; char temp2[200]; if (!strcmp(option->string, "dreamer") || !strcmp(option->string, "Dreamer")) { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef bundledir = CFBundleCopyBundleURL(mainBundle); CFStringRef stringref = CFURLCopyFileSystemPath(bundledir, kCFURLPOSIXPathStyle); CFStringGetCString(stringref, temp1, 200, kCFStringEncodingMacRoman); snprintf(temp2, sizeof(temp2), "%s/contents/MacOS/dreamer", temp1); game_set_engine_error(comm_init(temp2)); } else game_set_engine_error(comm_init(option->string)); #else game_set_engine_error(comm_init(option->string)); #endif comm_send("xboard\n"); comm_send("new\n"); comm_send("random\n"); comm_send("sd %i\n", config->cpu_level); comm_send("depth %i\n", config->cpu_level); if (config->difficulty == 0) comm_send("noquiesce\n"); if (config->player[WHITE] == PLAYER_UI && config->player[BLACK] == PLAYER_UI) comm_send("force\n"); if (config->player[WHITE] == PLAYER_ENGINE) comm_send("go\n"); in_game = 1; board_setup(&board); history = history_init(&board); move_list_init(&san_list); move_list_init(&fan_list); move_list_init(&fullalg_list); if (pgn_slot >= 0) if (game_load(pgn_slot)) { DBG_ERROR("Failed to load savegame in slot %i", pgn_slot); exit(1); } ui->update(history->view->board, NULL); while (in_game) { char *s; if ((s = comm_poll())) { DBG_LOG("Message from engine: '%s'", s); if (!history->result) { if ((!strncmp(s, "move ", 4) || strstr(s, "... ")) && config->player[history->last->board->turn] == PLAYER_ENGINE) { char *move_str = strrchr(s, ' ') + 1; board_t new_board = *history->last->board; move_t *engine_move; DBG_LOG("Parsing move string '%s'", move_str); engine_move = san_to_move(&new_board, move_str); if (!engine_move) engine_move = fullalg_to_move(&new_board, move_str); if (engine_move) { audio_play_sound(AUDIO_MOVE); do_move(engine_move, 1); free(engine_move); } else DBG_ERROR("Failed to parse move string '%s'", move_str); } else if (strstr(s, "llegal move")) game_undo(); /* Ignore result message if we've already determined a result ourselves. */ else { char *start = strchr(s, '{'); char *end = strchr(s, '}'); if (start && end && end > start) { char *comment = malloc(end - start); history->result = malloc(sizeof(result_t)); strncpy(comment, start + 1, end - start - 1); comment[end - start - 1] = '\0'; history->result->reason = comment; if (strstr(s, "1-0")) { history->result->code = RESULT_WHITE_WINS; ui->show_result(history->result); } else if (strstr(s, "1/2-1/2")) { history->result->code = RESULT_DRAW; ui->show_result(history->result); } else if (strstr(s, "0-1")) { history->result->code = RESULT_BLACK_WINS; ui->show_result(history->result); } else { free(history->result->reason); free(history->result); history->result = NULL; } } } } free(s); } ui->poll(); } comm_send("quit\n"); comm_exit(); history_exit(history); move_list_exit(&san_list); move_list_exit(&fan_list); move_list_exit(&fullalg_list); } ui->exit(); dbg_exit(); return 0; }