diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-03 19:41:23 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:54 +0200 |
commit | 93123e97251fc791c1cac193d675cce9a1ac2de6 (patch) | |
tree | 4486453695d6f715e767bd91bcee89c92f54f7ba /src/game/game.cpp | |
parent | 70b21e90d7be4d892b7d17440d64630e7ee1a575 (diff) |
feat: add moving cursor
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r-- | src/game/game.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index 2b09470..ee3a2b8 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -1,7 +1,12 @@ #include "game.hpp" -Game::Game(std::shared_ptr<IScene> scene, std::shared_ptr<IInputHandler> input_handler) - : _scene(std::move(scene)), _input_handler(std::move(input_handler)) +#include <utility> + +Game::Game(std::shared_ptr<IScene> scene, std::shared_ptr<IInputHandler> input_handler, + std::shared_ptr<CursorController> cursor_controller) + : _scene(std::move(scene)), + _input_handler(std::move(input_handler)), + _cursor_controller(std::move(cursor_controller)) { } @@ -22,6 +27,32 @@ void Game::run() exit(EXIT_SUCCESS); }); + auto cursor_controller = _cursor_controller; + + _input_handler->attach('k', + [&cursor_controller]() + { + cursor_controller->move<Direction::UP>(1U); + }); + + _input_handler->attach('j', + [&cursor_controller]() + { + cursor_controller->move<Direction::DOWN>(1U); + }); + + _input_handler->attach('h', + [&cursor_controller]() + { + cursor_controller->move<Direction::LEFT>(1U); + }); + + _input_handler->attach('l', + [&cursor_controller]() + { + cursor_controller->move<Direction::RIGHT>(1U); + }); + _input_handler->listen(); _scene->leave(); |