aboutsummaryrefslogtreecommitdiff
path: root/src/game/game.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-20 20:37:43 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:57 +0200
commit1972939ebde39a3e90a50b021b2322d028f344de (patch)
tree9ee0a7c78f082bec084189906f28dc679a20d339 /src/game/game.cpp
parente6644d6b235005de9ba1b9884472fa5f5d8d6074 (diff)
refactor: move updating status from the move cursor command
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r--src/game/game.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 5df3935..055e212 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -3,6 +3,7 @@
#include "commands/insert_cell.hpp"
#include "commands/move_cursor.hpp"
#include "commands/quit.hpp"
+#include "game/cursor_listener.hpp"
#include "strings.hpp"
#include <fmt/core.h>
@@ -16,6 +17,10 @@ Game::Game(const std::shared_ptr<IWindow> &window, const std::shared_ptr<IScene>
void Game::on_start() noexcept
{
+ auto cursor_listener = std::make_shared<CursorListener>(_scene);
+
+ _cursor_controller->subscribe(CursorEvent::POSITION_CHANGE, cursor_listener);
+
const auto window_size = _window->size();
const auto center_position =
@@ -50,11 +55,11 @@ Game::get_input_config() const noexcept
return {{'q', std::make_shared<QuitCommand>()},
{'i', std::make_shared<InsertCellCommand>(_cursor_controller, _scene)},
{'k', std::make_shared<MoveCursorCommand>(Vector2::up(), _cursor_controller,
- _scene, _window)},
+ _window)},
{'j', std::make_shared<MoveCursorCommand>(Vector2::down(), _cursor_controller,
- _scene, _window)},
+ _window)},
{'h', std::make_shared<MoveCursorCommand>(Vector2::left(), _cursor_controller,
- _scene, _window)},
- {'l', std::make_shared<MoveCursorCommand>(
- Vector2::right(), _cursor_controller, _scene, _window)}};
+ _window)},
+ {'l', std::make_shared<MoveCursorCommand>(Vector2::right(),
+ _cursor_controller, _window)}};
}