From 8a3dd5ac472a0c749338ac78dd5198d3819b629f Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Tue, 10 Dec 2024 09:56:22 +0100 Subject: fixed 0 division and duplicate start --- src/crepe/api/LoopManager.cpp | 1 - src/crepe/manager/LoopTimerManager.cpp | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index 15fa52d..9bb2183 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -63,7 +63,6 @@ void LoopManager::setup() { this->game_running = true; this->loop_timer.start(); this->scene_manager.load_next_scene(); - this->loop_timer.start(); } void LoopManager::render() { diff --git a/src/crepe/manager/LoopTimerManager.cpp b/src/crepe/manager/LoopTimerManager.cpp index e496a44..1d864ad 100644 --- a/src/crepe/manager/LoopTimerManager.cpp +++ b/src/crepe/manager/LoopTimerManager.cpp @@ -31,10 +31,11 @@ void LoopTimerManager::update() { if (this->delta_time > this->maximum_delta_time) { this->delta_time = this->maximum_delta_time; } - if(this->delta_time.count() <= 0){ - this->delta_time = std::chrono::duration(0.0); + if (this->delta_time.count() > 0.0) { + this->actual_fps = 1.0 / this->delta_time.count(); + } else { + this->actual_fps = INFINITY; } - this->actual_fps = 1.0 / this->delta_time.count(); this->elapsed_time += this->delta_time; this->last_frame_time = current_frame_time; -- cgit v1.2.3