diff options
author | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-09-25 12:57:18 -0400 |
---|---|---|
committer | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-09-25 12:57:18 -0400 |
commit | 1703f84121f18277c2a9bd671e204730c131c102 (patch) | |
tree | 73de6ae8aad4418cd19d55d5b468a20b404446ec | |
parent | be9d14233e9fc7b7c5e4fc3711125132e3cee151 (diff) |
Changed up time-step to see if it fixes desktop stuttering movement issues
-rw-r--r-- | src/engine.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 703b45e..a000979 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -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) |