#include "game.hpp" #include Game::Game(std::shared_ptr scene, std::shared_ptr input_handler, std::shared_ptr cursor_controller) : _scene(std::move(scene)), _input_handler(std::move(input_handler)), _cursor_controller(std::move(cursor_controller)) { } void Game::run() { _scene->enter(); _input_handler->enter_raw_mode(); auto scene = _scene; auto input_handler = _input_handler; _input_handler->attach('q', [&input_handler, &scene]() { input_handler->leave_raw_mode(); scene->leave(); exit(EXIT_SUCCESS); }); auto cursor_controller = _cursor_controller; _input_handler->attach('k', [&cursor_controller]() { cursor_controller->move(1U); }); _input_handler->attach('j', [&cursor_controller]() { cursor_controller->move(1U); }); _input_handler->attach('h', [&cursor_controller]() { cursor_controller->move(1U); }); _input_handler->attach('l', [&cursor_controller]() { cursor_controller->move(1U); }); _input_handler->listen(); _scene->leave(); }