aboutsummaryrefslogtreecommitdiff
path: root/src/engine/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/engine.cpp')
-rw-r--r--src/engine/engine.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp
index 4775fe4..f947a45 100644
--- a/src/engine/engine.cpp
+++ b/src/engine/engine.cpp
@@ -9,10 +9,12 @@
CLIGameEngine::CLIGameEngine(
IGameFactory game_factory,
ISceneFactory scene_factory,
+ IComponentRendererFactory component_renderer_factory,
std::shared_ptr<IUserInputObserver> user_input_observer,
std::shared_ptr<ICursorController> cursor_controller) noexcept
: _game_factory(std::move(game_factory)),
_scene_factory(std::move(scene_factory)),
+ _component_renderer_factory(std::move(component_renderer_factory)),
_user_input_observer(std::move(user_input_observer)),
_cursor_controller(std::move(cursor_controller))
{
@@ -22,6 +24,8 @@ void CLIGameEngine::start() noexcept
{
std::shared_ptr<IScene> scene = _scene_factory(_cursor_controller);
+ auto component_renderer = _component_renderer_factory(_cursor_controller);
+
scene->enter();
_cursor_controller->set_bounds(scene->size());
@@ -65,8 +69,17 @@ void CLIGameEngine::start() noexcept
game->on_update();
- last_update_time = std::chrono::system_clock::now();
+ for (auto [component, position] : scene->get_components())
+ {
+ if (component->get_need_render())
+ {
+ component_renderer->render(component, position);
+ component->set_need_render(false);
+ }
+ }
_user_input_observer->clear_currently_pressed();
+
+ last_update_time = std::chrono::system_clock::now();
}
}