]> git.localhorst.tv Git - l2e.git/blobdiff - src/app/Application.cpp
added timer facility
[l2e.git] / src / app / Application.cpp
index 80ebb5d1ac1c8ae51a63a508a4a763026d1b695e..fc1d3801d4ab6fe65f0ea8af622904e0eb01b194 100644 (file)
@@ -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();
@@ -159,6 +165,7 @@ void Application::HandleEvents() {
 void Application::UpdateWorld(Uint32 deltaT) {
        if (!CurrentState()) return;
        for (Uint32 i(0); i < deltaT; ++i) {
+               CurrentState()->PhysicsTimers().Update(0.001f);
                CurrentState()->UpdateWorld(0.001f);
        }
 }