From cbd7663b7f9cf7bf2b498f54b5d86c2ca37a5188 Mon Sep 17 00:00:00 2001 From: max-001 Date: Fri, 6 Dec 2024 09:56:54 +0100 Subject: Modified game loop --- src/crepe/api/LoopManager.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/crepe') diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index 2f8a0a7..90308a7 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -40,6 +40,7 @@ void LoopManager::fixed_update() { EventManager & ev = this->mediator.event_manager; ev.dispatch_events(); this->get_system().update(); + this->get_system().update(); this->get_system().update(); this->get_system().update(); } @@ -50,22 +51,17 @@ void LoopManager::loop() { while (game_running) { timer.update(); - + while (timer.get_lag() >= timer.get_fixed_delta_time()) { this->process_input(); this->fixed_update(); timer.advance_fixed_update(); } - + this->update(); this->render(); timer.enforce_frame_rate(); - - // Stop the game after 10 seconds, for testing purposes - if (timer.get_current_time() > 10) { - this->game_running = false; - } } } @@ -75,7 +71,6 @@ void LoopManager::setup() { this->scene_manager.load_next_scene(); timer.start(); timer.set_fps(200); - this->scene_manager.load_next_scene(); } void LoopManager::render() { @@ -84,7 +79,4 @@ void LoopManager::render() { this->get_system().update(); } -void LoopManager::update() { - this->get_system().update(); - this->get_system().update(); -} +void LoopManager::update() { this->get_system().update(); } -- cgit v1.2.3