]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
Changed up time-step to see if it fixes desktop stuttering movement issues
authorAndy Belle-Isle <drumsetmonkey@gmail.com>
Wed, 25 Sep 2019 16:57:18 +0000 (12:57 -0400)
committerAndy Belle-Isle <drumsetmonkey@gmail.com>
Wed, 25 Sep 2019 16:57:18 +0000 (12:57 -0400)
src/engine.cpp

index 703b45e248eb5478f65da62141c75f994e0e7cd5..a00097912867c43f96f9a7f9a03914f54b32b454 100644 (file)
@@ -84,8 +84,15 @@ void Engine::logicLoop(void)
                                     the logic loop is run during our first
                                     loop. */
 
+    auto start = mc::now();
     while (shouldRun()) {
-        auto start = mc::now();
+        auto end = start;
+        start = mc::now();
+        auto diff = start-end;
+        auto micros = cr::duration_cast<cr::microseconds>(diff);
+        auto msc = micros.count();
+        dt = static_cast<double>(msc) / 1000.0;
+        elapsed += dt;
 
         systems.update<InputSystem>(dt);
         //systems.update<ScriptSystem>(dt);
@@ -107,35 +114,27 @@ void Engine::logicLoop(void)
         }
 
         std::this_thread::yield();
-
-        auto end = mc::now();
-        auto diff = end - start;
-        auto micros = cr::duration_cast<cr::microseconds>(diff);
-        auto msc = micros.count();
-        dt = static_cast<double>(msc) / 1000.0;
-        elapsed += dt;
     }
 }
 
 void Engine::physicsLoop(void)
 {
     entityx::TimeDelta dt = 0; /**< Elapsed milliseconds since each loop */
-
+    auto start = mc::now();
     while (shouldRun()) {
-        auto start = mc::now();
+        auto end = start;
+        start = mc::now();
+
+        auto diff = start - end;
+        auto micros = cr::duration_cast<cr::microseconds>(diff);
+        auto msc = micros.count();
+        dt = static_cast<double>(msc) / 1000.0;
 
         // Update the entities physics/position
         systems.update<PhysicsSystem>(dt);
 
         std::this_thread::yield();
-
-        auto end = mc::now();
-        auto diff = end - start;
-        auto micros = cr::duration_cast<cr::microseconds>(diff);
-        auto msc = micros.count();
-        dt = static_cast<double>(msc) / 1000.0;
     }
-    std::cout << std::endl;
 }
 
 void Engine::renderLoop(void)