diff options
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r-- | src/game/game.cpp | 15 |
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)}}; } |