aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/LoopManager.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 15:01:46 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 15:01:46 +0100
commite49893e8de74534494792955c50ea0eabaf3ba38 (patch)
treec85a80001d4c17e467d69698defb628109559ecf /src/crepe/api/LoopManager.cpp
parent68bf20b491b4b7673c2ece7a6497b9faffd44eb1 (diff)
WIP fix LoopTimerManager
Diffstat (limited to 'src/crepe/api/LoopManager.cpp')
-rw-r--r--src/crepe/api/LoopManager.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp
index 4ca9928..aa4a21a 100644
--- a/src/crepe/api/LoopManager.cpp
+++ b/src/crepe/api/LoopManager.cpp
@@ -43,20 +43,19 @@ void LoopManager::setup() {
void LoopManager::loop() {
try {
+ while (game_running) {
+ this->loop_timer.update();
- while (game_running) {
- this->loop_timer.update();
+ while (this->loop_timer.get_lag() >= this->loop_timer.get_fixed_delta_time()) {
+ this->fixed_update();
+ this->loop_timer.advance_fixed_elapsed_time();
+ }
- while (this->loop_timer.get_lag() >= this->loop_timer.get_fixed_delta_time()) {
- this->fixed_update();
- this->loop_timer.advance_fixed_elapsed_time();
+ this->frame_update();
+ this->loop_timer.enforce_frame_rate();
}
-
- this->frame_update();
- this->loop_timer.enforce_frame_rate();
- }
}catch(const exception & e){
- Log::logf(Log::Level::ERROR, "Exception caught in main loop: %s", e.what());
+ Log::logf(Log::Level::ERROR, "Exception caught in main loop: {}", e.what());
this->event_manager.trigger_event<ShutDownEvent>(ShutDownEvent{});
}
}