diff options
Diffstat (limited to 'src/engine/engine.cpp')
-rw-r--r-- | src/engine/engine.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
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 <cstdlib> #include <fmt/core.h> +#include <iostream> #include <utility> 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<char, Callback> 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', |