aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-11 19:50:53 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-11 19:50:53 +0100
commite324ccb9b385b22db99575826a86501faba3a49d (patch)
tree8f245afc5662ac11a9e6433f3d7fa5f8f8c0e0a3 /src/crepe/system
parent9732dd4d51fa4a5115b639b090cca96574719380 (diff)
parent59954bfc14cdb32997a3fb09e6ee1b393a4dc027 (diff)
Merge branch 'master' into niels/UI
Diffstat (limited to 'src/crepe/system')
-rw-r--r--src/crepe/system/AISystem.cpp10
-rw-r--r--src/crepe/system/AnimatorSystem.cpp6
2 files changed, 9 insertions, 7 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();
}
}
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp
index d61ba35..31eb85c 100644
--- a/src/crepe/system/AnimatorSystem.cpp
+++ b/src/crepe/system/AnimatorSystem.cpp
@@ -2,7 +2,7 @@
#include "../api/Animator.h"
#include "../manager/ComponentManager.h"
-#include "api/LoopTimer.h"
+#include "../manager/LoopTimerManager.h"
#include "AnimatorSystem.h"
@@ -10,10 +10,10 @@ using namespace crepe;
void AnimatorSystem::update() {
ComponentManager & mgr = this->mediator.component_manager;
- LoopTimer & timer = this->mediator.timer;
+ LoopTimerManager & timer = this->mediator.loop_timer;
RefVector<Animator> animations = mgr.get_components_by_type<Animator>();
- double elapsed_time = timer.get_current_time();
+ unsigned long long elapsed_time = timer.get_elapsed_time().count();
for (Animator & a : animations) {
if (!a.active) continue;