void ClientApplication::Proc() { LoadScene(SceneList::FIRST); //prepare the time system typedef std::chrono::steady_clock Clock; Clock::time_point simTime = Clock::now(); Clock::time_point realTime; //The main loop while(activeScene->GetNextScene() != SceneList::QUIT) { //switch scenes when necessary if (activeScene->GetNextScene() != SceneList::CONTINUE) { LoadScene(activeScene->GetNextScene()); continue; } //update the current time realTime = Clock::now(); //simulate game time while (simTime < realTime) { //call each user defined function activeScene->RunFrame(); //~60 FPS simTime += std::chrono::duration<int, std::milli>(16); } //draw the game to the screen activeScene->RenderFrame(); } UnloadScene(); }
void ClientApplication::LoadScene(SceneList sceneIndex) { UnloadScene(); switch(sceneIndex) { //add scene creation calls here case SceneList::FIRST: case SceneList::CONWAY: activeScene = new Conway(); break; default: throw(std::logic_error("Failed to recognize the scene index")); } }
void Player::UnloadAllScenes() { Vector<SharedPtr<Scene>> scenes = loadedScenes_; for (unsigned i = 0; i < scenes.Size(); i++) { UnloadScene(scenes[i]); } assert(loadedScenes_.Size() == 0); }
//----------------------------------------------------------------------------- // Purpose: // Input : *filename - //----------------------------------------------------------------------------- void C_SceneEntity::LoadSceneFromFile( const char *filename ) { UnloadScene(); int sleepCount = 0; while ( scenefilecache->IsStillAsyncLoading( filename ) ) { ::Sleep( 10 ); ++sleepCount; if ( sleepCount > 10 ) { Assert( 0 ); break; } } m_pScene = LoadScene( filename ); }
C_SceneEntity::~C_SceneEntity( void ) { UnloadScene(); }
//----------------------------------------------------------------------------- // Purpose: // Input : *filename - //----------------------------------------------------------------------------- void C_SceneEntity::LoadSceneFromFile( const char *filename ) { UnloadScene(); m_pScene = LoadScene( filename ); }
/// \brief /// This overridable is called when loading is aborted. The default implementation calls UnloadScene and sets the m_bAborted flag SCENE_IMPEXP virtual void OnAbort() { m_bAborted = true; UnloadScene(); }
/// \brief /// Static helper function to clear the scene content, and prepare empty scene /// for use. static inline void ClearScene() { UnloadScene(); Vision::InitWorld(); }