aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/LoopManager.cpp
diff options
context:
space:
mode:
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{});
}
}