diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-05 00:03:10 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-05 00:03:10 +0100 |
commit | 8aa43f634c1a89f05681ffc5f3cd0a3477e50e71 (patch) | |
tree | a1321d75328da0952ba7bf294a8036f50debb60f /src/crepe/api/LoopManager.cpp | |
parent | d9e46281c1e24a5f23d779d314e5df87fa3317a3 (diff) | |
parent | cfb67ffddb9f4bb0357c2b9df4239bfee7364c5a (diff) |
added loopTimer to mediator and fixed update loop
Diffstat (limited to 'src/crepe/api/LoopManager.cpp')
-rw-r--r-- | src/crepe/api/LoopManager.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index 9bedbcc..040cb93 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -1,22 +1,19 @@ -#include <iostream> - #include "../facade/SDLContext.h" + #include "../system/AnimatorSystem.h" #include "../system/CollisionSystem.h" #include "../system/ParticleSystem.h" #include "../system/PhysicsSystem.h" #include "../system/RenderSystem.h" #include "../system/ScriptSystem.h" +#include "../manager/EventManager.h" -#include "../api/EventManager.h" #include "LoopManager.h" -#include "LoopTimer.h" using namespace crepe; using namespace std; LoopManager::LoopManager() { - this->loop_timer = make_unique<LoopTimer>(); this->load_system<AnimatorSystem>(); this->load_system<CollisionSystem>(); this->load_system<ParticleSystem>(); @@ -26,12 +23,11 @@ LoopManager::LoopManager() { EventManager::get_instance().subscribe<ShutDownEvent>([this](const ShutDownEvent& event) { return this->on_shutdown(event); }); - + this->loop_timer = make_unique<LoopTimer>(); + this->mediator.loop_timer = *loop_timer; } -void LoopManager::process_input() { - SDLContext::get_instance().handle_events(this->game_running); -} +void LoopManager::process_input() { this->sdl_context.handle_events(this->game_running); } void LoopManager::start() { this->setup(); @@ -59,15 +55,17 @@ void LoopManager::loop() { } void LoopManager::setup() { + + this->game_running = true; this->loop_timer->start(); - this->loop_timer->set_target_fps(60); + this->loop_timer->set_target_fps(200); } void LoopManager::render() { - if (this->game_running) { - this->get_system<RenderSystem>().update(); - } + if (!this->game_running) return; + + this->get_system<RenderSystem>().update(); } bool LoopManager::on_shutdown(const ShutDownEvent & e){ this->game_running = false; |