diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 15:04:36 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 15:04:36 +0100 |
commit | cd708c639c34cbc7d978686e54303c91f15954c0 (patch) | |
tree | a469b265dd6e7e362200290cc6267c0dd3927cf5 /src/crepe/system/AISystem.cpp | |
parent | dfa8ffbc03c4c1acd74fd14e54c6ee566a3c445c (diff) | |
parent | 68c9e7511ea52c6ee70d052bbdf2923cd68bfa8a (diff) |
Merge branch 'wouter/gameloop' of https://github.com/lonkaars/crepe into wouter/gameloop
Diffstat (limited to 'src/crepe/system/AISystem.cpp')
-rw-r--r-- | src/crepe/system/AISystem.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/crepe/system/AISystem.cpp b/src/crepe/system/AISystem.cpp index e2e36a5..ed22203 100644 --- a/src/crepe/system/AISystem.cpp +++ b/src/crepe/system/AISystem.cpp @@ -1,21 +1,23 @@ #include <algorithm> #include <cmath> -#include "api/LoopTimer.h" #include "manager/ComponentManager.h" +#include "manager/LoopTimerManager.h" #include "manager/Mediator.h" #include "AISystem.h" using namespace crepe; +using namespace std::chrono; void AISystem::update() { const Mediator & mediator = this->mediator; ComponentManager & mgr = mediator.component_manager; RefVector<AI> ai_components = mgr.get_components_by_type<AI>(); + LoopTimerManager & loop_timer = mediator.loop_timer; //TODO: Use fixed loop dt (this is not available at master at the moment) - double dt = LoopTimer::get_instance().get_delta_time(); + duration_t dt = loop_timer.get_delta_time(); // Loop through all AI components for (AI & ai : ai_components) { @@ -42,7 +44,7 @@ void AISystem::update() { // Calculate the acceleration (using the above calculated force) vec2 acceleration = force / rigidbody.data.mass; // Finally, update Rigidbody's velocity - rigidbody.data.linear_velocity += acceleration * dt; + rigidbody.data.linear_velocity += acceleration * duration_cast<seconds>(dt).count(); } } |