From 3dbf3b68c484704aafcda9fd05ae88a0337956ef Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 19 Mar 2022 13:28:29 +0100 Subject: feat: add inserting cells --- src/engine/engine.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/engine/engine.cpp') diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 2fc94fe..afa5924 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -2,11 +2,10 @@ #include "input_actions.hpp" #include "strings.hpp" - #include "util/function.hpp" -#include #include +#include #include CLIGameEngine::CLIGameEngine(IGameFactory game_factory, ISceneFactory scene_factory, @@ -41,14 +40,40 @@ void CLIGameEngine::start() noexcept fmt::arg("y", center_position.get_y()))); std::atexit(normalize_lambda( - [scene, this]() + [this, scene]() { scene->leave(); _input_handler->leave_raw_mode(); + + for (auto row : *scene->get_matrix()) + { + for (auto &col : row) + { + fmt::print("{}", col); + } + + fmt::print("\n"); + } + + std::cout.flush(); })); const std::unordered_map input_config = { {'q', InputActions::exit_success}, + {'i', + [this, scene]() + { + const auto position = _cursor_controller->where(); + + std::cout.put('x'); + std::cout.flush(); + + _cursor_controller->move_to(position); + + auto matrix = scene->get_matrix(); + + matrix->set(position - Vector2({.x = 0U, .y = 1U}), "#"); + }}, {'k', InputActions::move_cursor(Vector2::up(), _cursor_controller, scene, _window)}, {'j', -- cgit v1.2.3-18-g5258