aboutsummaryrefslogtreecommitdiff
path: root/src/engine/engine.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-19 13:28:29 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:56 +0200
commit3dbf3b68c484704aafcda9fd05ae88a0337956ef (patch)
treeb7a2d45811c0ed5e336f87c23369f3929322b0cc /src/engine/engine.cpp
parent55c93fe609888be73677317978959040cf35b2ff (diff)
feat: add inserting cells
Diffstat (limited to 'src/engine/engine.cpp')
-rw-r--r--src/engine/engine.cpp31
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',