std::string MenuState::Run(){ //Unset events from earlier Input::Clear(); //Clean up any previous exit settings UnsetExit(); //Call the script's Init State::Init(); Timer delta; delta.Start(); while (!mExit){ //EVENT POLLING Input::PollEvent(); if (Input::Quit()) SetExit("quit"); if (Input::KeyDown(SDL_SCANCODE_ESCAPE)) SetExit("quit"); //Testing camera panning if (Input::KeyDown(SDL_SCANCODE_SPACE) && mCamera->Scene() == "def") mCamera->Pan("test"); else if (Input::KeyDown(SDL_SCANCODE_SPACE) && mCamera->Scene() == "test") mCamera->Pan("def"); //Testing shared ptrs if (Input::KeyDown(SDL_SCANCODE_1)) mManager->PrintSharedPtrCount(); //LOGIC mCamera->Update(); mManager->Update(); //Call script's logic update State::LogicUpdate(); float deltaT = delta.Restart() / 1000.f; mManager->Move(deltaT); mCamera->Move(deltaT); //RENDERING Window::Clear(); //Call state's rendering for background effects State::RenderUpdate(); mManager->Draw(); //refresh window Window::Present(); Window::ShowAvgFps(false); } return mExitCode; }
std::string GameState::Run(){ //Start the render and physics threads //std::thread tRend(&GameState::RenderThread, this); //std::thread tPhys(&GameState::PhysicsThread, this); //std::mutex m; //Unset events from earlier Input::Clear(); //Cleanup any previous exit settings UnsetExit(); //Call the script's Init State::Init(); Timer delta; delta.Start(); while (!mExit){ //EVENT POLLING Input::PollEvent(); if (Input::Quit()) SetExit("quit"); if (Input::KeyDown(SDL_SCANCODE_ESCAPE)) SetExit("mIntro"); //Logic mCamera->Update(); mManager->Update(); mManager->SetCollisionMaps(mMap.get()); float deltaT = delta.Restart() / 1000.f; mManager->Move(deltaT); //Rendering Window::Clear(); mMap->Draw(mCamera); mManager->Draw(); Window::Present(); Window::ShowAvgFps(false); //Wait for notification //std::unique_lock<std::mutex> lock(m); //mCondVar.wait(lock); } //Join the threads back in //tRend.join(); //tPhys.join(); return mExitCode; }
void ESInputPlatform::Refresh () { SDL_Event event; while(SDL_PollEvent(&event)) { if(event.type == SDL_QUIT) { SetExit(); } } int numkeys; if(SDL_GetKeyState(&numkeys)[SDLK_F10]) { SetExit(); } }
void CEngine::Update() { if(m_pCore->GetExit()) { SetExit(true); return; } m_pCore->Update(); if(!m_pCore->GetLevelChanger()->ChangingLevel()) { float l_fElapsedTime = m_pCore->GetTimer()->GetElapsedTime(); if(m_pActiveProcess != NULL) m_pActiveProcess->Update(l_fElapsedTime); UpdateSystems(l_fElapsedTime); } }
void TileCharacter::SetChar(int index) { m_pTexture = L""; m_alt = false; m_pALT = L""; m_boundingBox = false; m_exit = false; m_spawn = false; switch(index) { case 0: Space(); break; case 1: NoSpace(); break; case 2: Removable(); break; case 3: SetExit(); break; case 4: SetSpawn(); break; default: Space(); break; } }