int main_loop(t_env *env) { int key; int ret_exec; set_winsize(env); if (env->load == 1) load_game(env); dup_plate(env->last_plate, env->plate, env->size); print_plate(env); while (refresh() == OK && (key = getch()) && clear() == OK) { if (key == KEY_RESIZE && (ret_exec = 0) == 0) set_winsize(env); if (test_window(env)) mvprintw(1, 1, "Affichage impossible"); else { dup_plate(env->last_plate, env->plate, env->size); if (key != KEY_RESIZE) ret_exec = exec_key(env, key); if (ret_exec != 0) return (ret_exec); } print_plate(env); } return (0); }
/*============================================================================= Set board to start a new game: put pieces in their initial positions, reset castling privileges, en-passant capture possibilities, and current turn. Precondition: there exists a file initial.in in the current directory with a valid initial chess configuration. ===========================================================================*/ void MaeBoard::reset () { clear (); if (!load_game ("initial.in")) clear (); }
//--------------------------------------------------------------------------- // Name: load_game [filename] // Desc: Test function to show how write a console function =) //--------------------------------------------------------------------------- static int csl_load_game(void) { int argc = csl_argc()+1; char path[60]; if(argc!=2) { csl_textout(1, "syntax: save_game [filename]"); } else { sprintf(path,"save/%s",csl_argv(1)); if(!load_game(path)) { csl_textoutf(1, "couldn't load game from %s",path); return CSLMSG_ERROR; } else { csl_textoutf(1, "loaded game from %s",path ); } } return CSLMSG_CLOSE; }
int loadgame_simple () { char home[MAX_PATH], path[MAX_PATH]; int rc = 0; if (get_app_dir (home, MAX_PATH) < 0) { message_box ("Error loading game."); return err_BadFileOpen; } sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav", home, game.crc, game.id, 0); erase_both(); stop_sound(); close_window(); if ((rc = load_game (path)) == err_OK) { message_box ("Game restored."); game.exit_all_logics = 1; menu_enable_all(); } else { message_box ("Error restoring game."); } return rc; }
Game::Game(shared_ptr<IView> _view) : userInterface(std::move(_view)) { Q_ASSERT(userInterface); players.push_back(std::make_unique<Player>("Player 1")); players.push_back(std::make_unique<Player>("Player 2")); auto v = userInterface.get(); // connect View to Presenter connect(v, SIGNAL(New_game(int)), this, SLOT(new_game(int))); connect(v, SIGNAL(Save_game(std::string)), this, SLOT(save_game(std::string))); connect(v, SIGNAL(Load_game(std::string)), this, SLOT(load_game(std::string))); connect(v, SIGNAL(Host_game(std::string)), this, SLOT(host_game(std::string))); connect(v, SIGNAL(Join_game(std::string)), this, SLOT(join_game(std::string))); connect(v, SIGNAL(Leave()), this, SLOT(leave())); connect(v, SIGNAL(Put_stone(int,int)), this, SLOT(put_stone(int,int))); connect(v, SIGNAL(Rotate(IView::quadrant,IView::turn)), this, SLOT(rotate(IView::quadrant,IView::turn))); // connect Presenter to View connect(this, SIGNAL(draw_stone(int,int,IView::color)),v,SLOT(Draw_stone(int,int,IView::color))); connect(this, SIGNAL(set_control_settings(IView::control_setting)),v,SLOT(Set_control_settings(IView::control_setting))); connect(this, SIGNAL(message(string)), v, SLOT(Show_message(string))); }
void window(char *file) { int loop; unsigned int framelimit; framelimit = 0; loop = 0; game.file = file; if (init_all() == 0 && game.map != NULL) { load_audio(); //load_intro(); while (loop == 0) { loop = get_input_menu(); load_menu(); while (loop == 1) { loop = get_input_game(); load_game(); framelimit = delay(framelimit); } framelimit = delay(framelimit); } } exit_game(); }
static void load_game_menu_cb(void) { GtkWidget *dialog; dialog = gtk_file_chooser_dialog_new( /* Dialog caption */ _("Open Game"), GTK_WINDOW(toplevel), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), default_game); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { char *file; file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog)); load_game(file, TRUE); g_free(file); scale_map(gmap); guimap_display(gmap); } gtk_widget_destroy(dialog); }
int save_load_interface(int which) { // use the CHOICE_ defines int outcome=1; char temp[80]; if (which == CHOICE_SAVE) { outcome = save_game (&gs); if (outcome == 1) sprintf(temp,"Saving FAILED."); else sprintf(temp,"Saving successful!"); } else if (which == CHOICE_LOAD) { outcome = load_game (&gs); if (outcome == 1) sprintf(temp,"Loading FAILED."); else sprintf(temp,"Loading successful!"); } else { // what the shit? } bool done = false; while (!done) { SDL_Event event; while (SDL_PollEvent(&event)) { // check for messages switch (event.type) { // exit if the window is closed case SDL_QUIT: done = true; break; // check for keypresses case SDL_KEYDOWN: { if (event.key.keysym.sym == SDLK_RETURN) { if (outcome == 0) return CODE_MAIN_GAME_INTERFACE; else if (which == CHOICE_SAVE) return CODE_MAIN_GAME_INTERFACE; else if (which == CHOICE_LOAD) return CODE_MAIN_MENU; else { /* what the shit man */ } } } } // end switch } // end of message processing print_full_picture(BITMAPS[IMG_FULL_SAVELOAD]); if (which == CHOICE_SAVE) put_text_at(-1,300,"SAVING..."); else if (which == CHOICE_LOAD) put_text_at(-1,300,"LOADING..."); put_text_at(-1,400,temp); put_text_at(-1,500,"Press ENTER to continue."); SDL_Flip(MAIN_SCREEN); SDL_Delay(100); } return 0; }
/** * Handles save of current game to selected file, * denoted by the i of the given file_btn */ int on_select_load_file(Control* file_btn) { game = load_game(file_btn->i); if (game == NULL ) { //TODO no saved game - error dialog? return 0; } return !show_player_select(get_root(file_btn), empty_select, on_select_player, on_cancel); }
void templateAppInit(int width, int height) { GFX_start(); glViewport(0.0f, 0.0f, width, height); GFX_set_matrix_mode(PROJECTION_MATRIX); GFX_load_identity(); GFX_set_orthographic((float)height / (float)width, 15.0f, (float)width / (float)height, 1.0f, 100.0f, -90.0f); load_game(); }
static void select_click_handler(ClickRecognizerRef recognizer, void *context) { if (!playing && lost) { restart_after_loss(); return; } if (!playing && !lost && (load_choice < 2)) { setup_game(); if (can_load && (load_choice == 1)) { load_game(); } if (!s_timer) { drop_block(); s_timer = app_timer_register(tick_time, game_tick, NULL); } return; } if (!playing && (load_choice == 2)) { // kamotswolf - had to modify several things in here to add new option option_shadows_buffer = !option_shadows_buffer; persist_write_bool(OPTION_SHADOWS_KEY, option_shadows_buffer); if(option_shadows_buffer) { text_layer_set_text(option_shadows_layer, "Drop Shadows ON"); } else { text_layer_set_text(option_shadows_layer, "Drop Shadows OFF"); } //layer_mark_dirty(s_title_pane_layer); return; } if (paused) { paused = false; s_timer = app_timer_register(tick_time, game_tick, NULL); layer_remove_from_parent(text_layer_get_layer(paused_label_layer)); return; } if (blockType == -1) { return; } GPoint newPos[4]; rotate_block(newPos, block, blockType, rotation); bool should_rotate = true; for (int i=0; i<4; i++) { if (newPos[i].x < 0 || newPos[i].x > 9) { should_rotate = false; } if (newPos[i].y < 0 || newPos[i].y > 19) { should_rotate = false; } if (grid[newPos[i].x][newPos[i].y]) { should_rotate = false; } } if (!should_rotate) { return; } for (int i=0; i<4; i++) { block[i] = newPos[i]; } rotation = (rotation + 1) % 4; layer_mark_dirty(s_left_pane_layer); }
//on slot click load the game or save it static void on_slot_click(gui_control* target, gui_control* window, gui_size x, gui_size y) { int slot = target->state.istate; int mode = target->parent->state.istate; gui_child_pop(window); if (mode == LOAD_MODE) load_game(window, slot); else if (mode == SAVE_MODE) save_game(window, slot); }
static void valid_key(t_event *e) { if (e->menu_select == 0) load_game(e); else if (e->menu_select == 1) { e->menu_select = 0; e->menu = TEXTURE_EDITOR; } else wolf_exit(e); }
void templateAppInit( int width, int height ) { atexit( templateAppExit ); GFX_start(); glViewport( 0.0f, 0.0f, width, height ); glGetIntegerv( GL_VIEWPORT, viewport_matrix ); load_game(); }
void MyGame::menu_first_(void) { if (input_.isKeyDown(gdl::Keys::Return) == true && this->key_ == false) { switch (this->items_.update(0, this->posMenu_.what_)) { case OPTION_ONE: { this->posMenu_.what_ = MENU_MAP; this->posMenu_.who_ = OPTION_ONE; this->items_.update(this->posMenu_.who_); break; } case OPTION_TWO: { if (this->items_.isNewGame() == false) { this->camera_.reset_cam_game(this->options_->getXMap(), this->options_->getYMap()); this->posMenu_.where_ = GAME; this->panel_.initialize(this->options_->getXMap(), -this->options_->getYMap(), 0); } break; } case OPTION_THR: { if (load_game() == true) { music_->playSong("gameS"); this->camera_.reset_cam_game(this->options_->getXMap(), this->options_->getYMap()); this->posMenu_.where_ = GAME; this->panel_.initialize(this->options_->getXMap(), -this->options_->getYMap(), 0); this->items_.setNewGame(false); } break; } case OPTION_FOU: { this->posMenu_.what_ = MENU_OPTGEN; this->posMenu_.who_ = OPTION_ONE; this->items_.update(this->posMenu_.who_); break; } case MAX_MENU: { save_game(); this->window_.close(); break; } } } }
void gui_load_game(struct GuiButton *gbtn) { struct PlayerInfo *player; player=get_my_player(); if (!load_game(gbtn->field_1B)) { ERRORLOG("Loading game %d failed; quitting.",(int)gbtn->field_1B); // Even on quit, we still should unpause the game set_players_packet_action(player, PckA_TogglePause, 0, 0, 0, 0); quit_game = 1; return; } set_players_packet_action(player, PckA_TogglePause, 0, 0, 0, 0); }
void Gamebuino::changeGame(){ display.clear(); display.print("LOADING..."); display.update(); load_game(loader); display.persistance = false; while(1){ if(update()){ display.println("\nNo SD card or\nno LOADER.HEX\n\nA:Exit"); if(buttons.pressed(BTN_A)) break; } } }
enum plugin_status plugin_start (const void *parameter) { (void) parameter; rb->srand (*rb->current_tick); /* Load HighScore if any */ highscore_load(SCORE_FILE, highscores, NUM_SCORES); #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif #ifdef HAVE_LCD_BITMAP rb->lcd_setfont (FONT_SYSFIXED); #else if (!pgfx_init(4, 2)) { rb->splash(HZ*2, "Old LCD :("); return PLUGIN_OK; } #endif /* Turn off backlight timeout */ backlight_ignore_timeout(); load_game(); resume_file = resume; while(!rockblox_loop()) { if(!resume) { int position = highscore_update(rockblox_status.score, rockblox_status.level, "", highscores, NUM_SCORES); if (position != -1) { if (position == 0) rb->splash(HZ*2, "New High Score"); highscore_show(position, highscores, NUM_SCORES, true); } } } #ifndef HAVE_LCD_BITMAP pgfx_release(); #endif /* Save user's HighScore */ highscore_save(SCORE_FILE, highscores, NUM_SCORES); backlight_use_settings(); return PLUGIN_OK; }
int main(int argc, char **argv) { if (argc < 2) { printf("You must load a game. Exiting\n"); return 1; } initialize_chip(); int load_status = load_game(argv[1]); if (load_status != 1) { printf("Could not load game: %s. Exiting\n", argv[1]); return 1; } printf("Game loaded!\n"); return 0; }
bool retro_load_game(const struct retro_game_info *info) { enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) return false; struct retro_frame_time_callback frame_cb = { frame_time_cb, 1000000 / 60 }; frame_cb.callback(frame_cb.reference); environ_cb(RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK, &frame_cb); load_game(); (void)info; return true; }
int loadgame_dialog () { char home[MAX_PATH], path[MAX_PATH]; int rc, slot = 0; int hm, vm, hp, vp; /* box margins */ int w; hm = 2; vm = 3; hp = hm * CHAR_COLS; vp = vm * CHAR_LINES; w = (40 - 2 * hm) - 1; if (get_app_dir (home, MAX_PATH) < 0) { message_box ("Error loading game."); return err_BadFileOpen; } sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id); erase_both(); stop_sound(); draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp); print_text ("Select a game which you wish to\nrestore:", 0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR); print_text ("Press ENTER to select, ESC cancels", 0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR); slot = select_slot (path); if (slot < 0) { message_box ("Game NOT restored."); return err_OK; } sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav", home, game.crc, game.id, slot); if ((rc = load_game (path)) == err_OK) { message_box ("Game restored."); game.exit_all_logics = 1; menu_enable_all(); } else { message_box ("Error restoring game."); } return rc; }
int main(int argc, char *argv[]) { initial(); if (!strcmp (argv[1], "-r")) load_game (argv[2]); gameloop(); v_reset_mode(); m_hide(); m_close(); save_game (GAMEFILE); }
bool retro_load_game(const struct retro_game_info *game) { enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) return false; struct retro_frame_time_callback frame_cb = { frame_time_cb, 1000000 / 60 }; frame_cb.callback(frame_cb.reference); environ_cb(RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK, &frame_cb); struct retro_audio_callback audio_cb = { emit_audio, audio_set_state }; use_audio_cb = environ_cb(RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK, &audio_cb); load_game(); return true; }
void start_game_load_savegame_on_startup() { if (loadSaveGameOnStartup != NULL) { int saveGameNumber = 1000; const char *sgName = strstr(loadSaveGameOnStartup, "agssave."); if (sgName != NULL) { sscanf(sgName, "agssave.%03d", &saveGameNumber); } current_fade_out_effect(); int loadGameErrorCode = load_game(loadSaveGameOnStartup, saveGameNumber); if (loadGameErrorCode) { quitprintf("Unable to resume the save game. Try starting the game over. (Error: %s)", load_game_errors[-loadGameErrorCode]); } } }
// 下一手棋 void play() { int ret; int ply, turn, time_limit; int chsbrd[BOARD_SIZE]; int score; int r, move_type; int MaxDepth; clock_t t; printf("inputting board\n"); ret = load_game("board.txt", piece_num, chsbrd, &turn, &time_limit); transform_board(board, chsbrd); dark_num = get_dark_num(board); red_num = get_piece_num(RED, piece_num); black_num = get_piece_num(BLACK, piece_num); best_src = 0; best_dest = 0; if(dark_num == PIECE_NUM) move_type = REVEAL_PIECE; else move_type = MOVE_PIECE; if(move_type == MOVE_PIECE){ printf("searching\n"); clock_limit = clock() + time_limit * CLK_TCK; if(time_limit < 20) max_depth = 6; else max_depth = (int) (log(time_limit / 20) / log(3)) * 2 + 6; score = search(board, piece_num, dark_num, red_num, black_num, turn, 1, max_depth, clock_limit); } move_type = (best_dest == -1) ? 1 : 0; if(best_src == 0){ move_type = REVEAL_PIECE; printf("revealing\n"); reveal(board); } best_src = translate_position(board, best_src); best_dest = translate_position(board, best_dest); printf("outputing\n\n"); output_move("move.txt", move_type, best_src, best_dest, score); }
void load( void ) { Playsound(18,22050,0,0,0); choice_start(); "&savegameinfo" "&savegameinfo" "&savegameinfo" "&savegameinfo" "&savegameinfo" "&savegameinfo" "&savegameinfo" "&savegameinfo" "&savegameinfo" "&savegameinfo" choice_end(); int &mycrap = game_exist(&result); if (&mycrap == 0) goto again; sp_brain(1, 1); sp_nohit(1, 0); stopmidi(); script_attach(1000); //script now can't die when the load is preformed.. init("load_sequence_now graphics\dink\walk\ds-w1- 71 43 38 72 -14 -9 14 9"); init("load_sequence_now graphics\dink\walk\ds-w2- 72 43 37 69 -13 -9 13 9"); init("load_sequence_now graphics\dink\walk\ds-w3- 73 43 38 72 -14 -9 14 9"); init("load_sequence_now graphics\dink\walk\ds-w4- 74 43 38 72 -12 -9 12 9"); init("load_sequence_now graphics\dink\walk\ds-w6- 76 43 38 72 -13 -9 13 9"); init("load_sequence_now graphics\dink\walk\ds-w7- 77 43 38 72 -12 -10 12 10"); init("load_sequence_now graphics\dink\walk\ds-w8- 78 43 37 69 -13 -9 13 9"); init("load_sequence_now graphics\dink\walk\ds-w9- 79 43 38 72 -14 -9 14 9"); init("load_sequence_now graphics\dink\idle\ds-i2- 12 250 33 70 -12 -9 12 9"); init("load_sequence_now graphics\dink\idle\ds-i4- 14 250 30 71 -11 -9 11 9"); init("load_sequence_now graphics\dink\idle\ds-i6- 16 250 36 70 -11 -9 11 9"); init("load_sequence_now graphics\dink\idle\ds-i8- 18 250 32 68 -12 -9 12 9"); load_game(&result); //loading a game kills ALL tasks }
int loadgame_simple () { char home[MAX_PATH], path[MAX_PATH]; int rc = 0; printf("here?\n"); #ifdef DREAMCAST uint8 addr, port, unit; addr = maple_first_vmu(); if (addr) { maple_create_port (addr, &port, &unit); sprintf (g_vmu_port, "%c%d", port + 'a', unit); } else { message_box("No VMU found."); return err_OK; } sprintf(path, VMU_PATH, g_vmu_port, game.id, slot); #else if (get_app_dir (home, MAX_PATH) < 0) { message_box ("Error loading game."); return err_BadFileOpen; } sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav", home, game.crc, game.id, 0); #endif erase_both(); stop_sound(); close_window(); if ((rc = load_game (path)) == err_OK) { message_box ("Game restored."); game.exit_all_logics = 1; menu_enable_all(); } else { message_box ("Error restoring game."); } return rc; }
void key_pressed(GLFWwindow* w, int key, int scancode, int action, int mods) { game_t* g = (game_t*)glfwGetWindowUserPointer(w); game_event_t ev = {0}; ev.type = EVENT_KEY; ev.keyPressed = (action == GLFW_PRESS || action == GLFW_REPEAT); if(key == GLFW_KEY_ESCAPE) { glfwSetWindowShouldClose(w, true); return; } else if(key == GLFW_KEY_R && action == GLFW_RELEASE) { g->lastLoaded = 0; memset(g->c.storage, g->c.size, 0); if(!load_game(g)) { glfwSetWindowShouldClose(w, true); return; } g->init(&g->c, g->width, g->height); return; } else if(key == GLFW_KEY_W) { // QWERTY !! ev.keyAction = DIRECTION_UP; } else if(key == GLFW_KEY_D) { ev.keyAction = DIRECTION_RIGHT; } else if(key == GLFW_KEY_S) { ev.keyAction = DIRECTION_DOWN; } else if(key == GLFW_KEY_A) { ev.keyAction = DIRECTION_LEFT; } else { return; } g->event(&g->c, ev); }
void click () { int game = choice ("&savegameinfo;", "&savegameinfo;", "&savegameinfo;", "&savegameinfo;", "&savegameinfo;", "&savegameinfo;", "&savegameinfo;", "&savegameinfo;", "&savegameinfo;", "&savegameinfo;", "Nevermind"); if (game == 11 || !game_exist (game)) return; stopmidi (); stopcd (); load_game (game); kill_this_task (); }
void menu(void) { int enter; write(1, "Bonjour, veuillez choisir une option\n", 38); write(1, "(N)ew game\n", 12); write(1, "(L)oad game\n", 13); write(1, "(R)egles\n", 9); write(1, "(E)xit\n", 8); enter = fgetc(fdopen(0, "r")); if (enter == 'N' || enter == 'n') new_game(); if (enter == 'L' || enter == 'l') load_game(); // if (enter == 'R' || enter == 'r') // write_file(""); if (enter == 'E' || enter == 'e') return ; write(1, "\n", 1); menu(); }