From 38f14606c78c119d452f302f17329455e29a9a6f Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 10 Mar 2022 19:12:31 +0100 Subject: refactor: rename game initializer & move input config --- src/input_actions.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/input_actions.cpp (limited to 'src/input_actions.cpp') diff --git a/src/input_actions.cpp b/src/input_actions.cpp new file mode 100644 index 0000000..854dc62 --- /dev/null +++ b/src/input_actions.cpp @@ -0,0 +1,35 @@ +#include "input_actions.hpp" + +#include + +namespace InputActions +{ + +void exit_success() +{ + exit(EXIT_SUCCESS); +} + +Callback move_cursor(const Vector2 &direction, + const std::shared_ptr &cursor_controller, + const std::shared_ptr &window) +{ + return [direction, cursor_controller, window]() + { + constexpr int32_t amount = 1; + + const auto new_position = + cursor_controller->where().to_direction(direction, amount); + + const auto window_size = window->size(); + + if (window_size.validate_coords(new_position) != CoordsValidation::VALID) + { + return; + } + + cursor_controller->move_to(new_position); + }; +} + +} // namespace InputActions -- cgit v1.2.3-18-g5258