void Engine::load() { TCODZip zip; zip.loadFromFile("game.sav"); //load the map int width=zip.getInt(); int height=zip.getInt(); map = new Map(width,height); map->load(zip); //then the player player=new Actor(0,0,0,NULL,TCODColor::white); player->load(zip); map->actors.push(player); // the stairs stairs=new Actor(0,0,0,NULL,TCODColor::white); stairs->load(zip); map->actors.push(stairs); map->sendToBack(stairs); //then all other actors int nbActors=zip.getInt(); while (nbActors > 0) { Actor *actor = new Actor(0,0,0,NULL,TCODColor::white); actor->load(zip); map->actors.push(actor); map->sendToBack(actor); nbActors--; } //finally the message log topGui->load(zip); }
void Engine::Load(void) { engine.gui_->menu_.Clear(); engine.gui_->menu_.AddItem(Menu::NEW_GAME, "New game"); if (TCODSystem::fileExists("game.sav")) { engine.gui_->menu_.AddItem(Menu::CONTINUE, "Continue"); } engine.gui_->menu_.AddItem(Menu::EXIT, "Exit"); Menu::MenuItemCode menuItem = engine.gui_->menu_.Pick(); if ((menuItem == Menu::EXIT) || (menuItem == Menu::NONE )) { // Exit or window closed exit(0); } else if (menuItem == Menu::NEW_GAME) { // New game engine.Term(); engine.Init(); } else { TCODZip zip; // continue a saved game engine.Term(); zip.loadFromFile("game.sav"); // load the map int32_t width = zip.getInt(); int32_t height = zip.getInt(); map_ = new Map(width, height); map_->Load(zip); // then the player player_ = new Actor(0, 0, 0, NULL, TCODColor::white); actors_.push(player_); player_->Load(zip); // then all other actors int32_t nbActors = zip.getInt(); while (nbActors > 0) { Actor *actor = new Actor(0, 0, 0, NULL, TCODColor::white); actor->Load(zip); actors_.push(actor); nbActors--; } // finally the message log gui_->Load(zip); // to force FOV recomputation gameStatus = STARTUP; } }
void Engine::Load(bool pause) { bool shouldLeave = false; TCODZip zip; while(!shouldLeave) { TCODConsole::root->clear(); TCODConsole::setFade(255, TCODColor::black); e->gui->menu.Clear(); e->gui->menu.AddItem(Menu::MIC_NEW_GAME, "New Game"); if(TCODSystem::fileExists("game.sav")) { zip.loadFromFile("game.sav"); int version = zip.getInt(); if(version == SAVEGAME_VERSION) { e->gui->menu.AddItem(Menu::MIC_CONTINUE, "Continue"); } } e->gui->menu.AddItem(Menu::MIC_EXIT, "Exit"); Menu::menu_item_code menuItem = e->gui->menu.Pick(true, 2, 2); if(menuItem == Menu::MIC_EXIT || menuItem == Menu::MIC_NONE) { e->leaveGame = true; shouldLeave = true; } else if(menuItem == Menu::MIC_NEW_GAME) { shouldLeave = true; } else if(menuItem == Menu::MIC_CONTINUE) { shouldLeave = true; e->Close(); int width = zip.getInt(); int height = zip.getInt(); map = new Map(width, height); map->Load(zip); player = new Actor(0, 0); e->AddActorToArena(player); player->Load(zip); int numberOfallActors = zip.getInt(); while(numberOfallActors > 0) { Actor* actor = new Actor(0, 0); actor->Load(zip); e->AddActorToWorld(actor); numberOfallActors--; } gui->Load(zip); gameStatus = GAME_STATUS_MAIN; } } }