aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/AISystem.cpp
diff options
context:
space:
mode:
authorWboerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-11 19:40:58 +0100
committerGitHub <noreply@github.com>2024-12-11 19:40:58 +0100
commit59954bfc14cdb32997a3fb09e6ee1b393a4dc027 (patch)
treef1da5eeb955bc44fd4cf3bb22bcaf989116f0ef8 /src/crepe/system/AISystem.cpp
parent30c17c98e54c1534664de08ca3838c40c859d166 (diff)
parenta464096dfff2ee4605e77852020e6a5c0fa5aa58 (diff)
Merge pull request #63 from lonkaars/wouter/gameloop
gameloop improvements + Singelton removal
Diffstat (limited to 'src/crepe/system/AISystem.cpp')
-rw-r--r--src/crepe/system/AISystem.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/crepe/system/AISystem.cpp b/src/crepe/system/AISystem.cpp
index 7f04432..d231c7c 100644
--- a/src/crepe/system/AISystem.cpp
+++ b/src/crepe/system/AISystem.cpp
@@ -1,22 +1,24 @@
#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;
- LoopTimer & timer = mediator.timer;
+ LoopTimerManager & timer = mediator.loop_timer;
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 = timer.get_delta_time();
+ duration_t dt = loop_timer.get_delta_time();
// Loop through all AI components
for (AI & ai : ai_components) {
@@ -43,7 +45,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();
}
}