#include "game.hpp" #include "commands/insert_cell.hpp" #include "commands/move_cursor.hpp" #include "commands/quit.hpp" #include "strings.hpp" #include #include Game::Game(const std::shared_ptr &window, const std::shared_ptr &scene, const std::shared_ptr &cursor_controller) noexcept : _window(window), _scene(scene), _cursor_controller(cursor_controller) { } void Game::on_start() noexcept { const auto window_size = _window->size(); const auto center_position = Vector2({.x = static_cast(window_size.get_width()) / 2, .y = static_cast(window_size.get_height()) / 2}); _cursor_controller->move_to(center_position); _scene->write_status(fmt::format(STATUS_BAR_COORDINATES, fmt::arg("x", center_position.get_x()), fmt::arg("y", center_position.get_y()))); } void Game::on_exit() const noexcept { for (auto row : *_scene->get_matrix()) { for (auto &col : row) { fmt::print("{}", col); } fmt::print("\n"); } std::cout.flush(); } std::unordered_map> 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)}, {'j', std::make_shared(Vector2::down(), _cursor_controller, _scene, _window)}, {'h', std::make_shared(Vector2::left(), _cursor_controller, _scene, _window)}, {'l', std::make_shared( Vector2::right(), _cursor_controller, _scene, _window)}}; }