X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FApplication.cpp;h=c1e4f15311526ec5f767078d5faf30d5d9a72eb5;hb=64c314421a700696260d73395776634dc64fc46c;hp=80ebb5d1ac1c8ae51a63a508a4a763026d1b695e;hpb=2a0eca649009f78028db286a67a532429cab5b88;p=l2e.git diff --git a/src/app/Application.cpp b/src/app/Application.cpp index 80ebb5d..c1e4f15 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -28,7 +28,7 @@ Application::~Application() { State *Application::CurrentState() { - return states.top(); + return states.empty() ? 0 : states.top(); } void Application::UpdateState() { @@ -120,11 +120,17 @@ void Application::Run() { void Application::Loop() { Uint32 now(SDL_GetTicks()); Uint32 deltaT(now - last); + GlobalTimers().Update(deltaT); if (deltaT > 34) deltaT = 34; + if (CurrentState()) { + CurrentState()->GraphicsTimers().Update(deltaT); + } HandleEvents(); - UpdateWorld(deltaT); - Render(); + if (!StateChangePending()) { + UpdateWorld(deltaT); + Render(); + } last = now; UpdateState(); @@ -153,12 +159,13 @@ void Application::HandleEvents() { break; } } - CurrentState()->HandleInput(input); + CurrentState()->HandleEvents(input); } void Application::UpdateWorld(Uint32 deltaT) { if (!CurrentState()) return; for (Uint32 i(0); i < deltaT; ++i) { + CurrentState()->PhysicsTimers().Update(0.001f); CurrentState()->UpdateWorld(0.001f); } }