diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-10 19:12:31 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:55 +0200 |
commit | 38f14606c78c119d452f302f17329455e29a9a6f (patch) | |
tree | 03f6dfd9d3576e87260f7cb3bc436ad076b629c5 /src/input_actions.cpp | |
parent | 09848ad31af6a1c70d64fccee711e231afb5a77f (diff) |
refactor: rename game initializer & move input config
Diffstat (limited to 'src/input_actions.cpp')
-rw-r--r-- | src/input_actions.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
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 <fmt/core.h> + +namespace InputActions +{ + +void exit_success() +{ + exit(EXIT_SUCCESS); +} + +Callback move_cursor(const Vector2 &direction, + const std::shared_ptr<ICursorController> &cursor_controller, + const std::shared_ptr<IWindow> &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 |