aboutsummaryrefslogtreecommitdiff
path: root/src/input_actions.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-10 19:12:31 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:55 +0200
commit38f14606c78c119d452f302f17329455e29a9a6f (patch)
tree03f6dfd9d3576e87260f7cb3bc436ad076b629c5 /src/input_actions.cpp
parent09848ad31af6a1c70d64fccee711e231afb5a77f (diff)
refactor: rename game initializer & move input config
Diffstat (limited to 'src/input_actions.cpp')
-rw-r--r--src/input_actions.cpp35
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