From 1972939ebde39a3e90a50b021b2322d028f344de Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 20 Mar 2022 20:37:43 +0100 Subject: refactor: move updating status from the move cursor command --- src/game/game.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/game/game.cpp') 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 @@ -16,6 +17,10 @@ Game::Game(const std::shared_ptr &window, const std::shared_ptr void Game::on_start() noexcept { + auto cursor_listener = std::make_shared(_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()}, {'i', std::make_shared(_cursor_controller, _scene)}, {'k', std::make_shared(Vector2::up(), _cursor_controller, - _scene, _window)}, + _window)}, {'j', std::make_shared(Vector2::down(), _cursor_controller, - _scene, _window)}, + _window)}, {'h', std::make_shared(Vector2::left(), _cursor_controller, - _scene, _window)}, - {'l', std::make_shared( - Vector2::right(), _cursor_controller, _scene, _window)}}; + _window)}, + {'l', std::make_shared(Vector2::right(), + _cursor_controller, _window)}}; } -- cgit v1.2.3-18-g5258