aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/InputSystem.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-04 20:13:09 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-04 20:13:09 +0100
commit66fdcffaddb0ab31d12b6b1d7892a8edaa31af65 (patch)
tree6c6692e0489133ac5264d53f7dc5a1e3d5be9320 /src/crepe/system/InputSystem.cpp
parent6454975779acb39d7d546e11855a07a952e68e5b (diff)
make format
Diffstat (limited to 'src/crepe/system/InputSystem.cpp')
-rw-r--r--src/crepe/system/InputSystem.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp
index bbf2547..21ec24b 100644
--- a/src/crepe/system/InputSystem.cpp
+++ b/src/crepe/system/InputSystem.cpp
@@ -152,7 +152,7 @@ void InputSystem::handle_click(const MouseButton & mouse_button, const int world
for (Button & button : buttons) {
RefVector<Transform> transform_vec
= mgr.get_components_by_id<Transform>(button.game_object_id);
- Transform& transform(transform_vec.front().get());
+ Transform & transform(transform_vec.front().get());
if (button.active
&& this->is_mouse_inside_button(world_mouse_x, world_mouse_y, button, transform)) {
@@ -162,20 +162,17 @@ void InputSystem::handle_click(const MouseButton & mouse_button, const int world
}
bool InputSystem::is_mouse_inside_button(const int mouse_x, const int mouse_y,
- const Button &button, const Transform &transform) {
- int actual_x = transform.position.x + button.offset.x;
- int actual_y = transform.position.y + button.offset.y;
-
- int half_width = button.dimensions.x / 2;
- int half_height = button.dimensions.y / 2;
-
- // Check if the mouse is within the button's boundaries
- return mouse_x >= actual_x - half_width
- && mouse_x <= actual_x + half_width
- && mouse_y >= actual_y - half_height
- && mouse_y <= actual_y + half_height;
-}
+ const Button & button, const Transform & transform) {
+ int actual_x = transform.position.x + button.offset.x;
+ int actual_y = transform.position.y + button.offset.y;
+ int half_width = button.dimensions.x / 2;
+ int half_height = button.dimensions.y / 2;
+
+ // Check if the mouse is within the button's boundaries
+ return mouse_x >= actual_x - half_width && mouse_x <= actual_x + half_width
+ && mouse_y >= actual_y - half_height && mouse_y <= actual_y + half_height;
+}
void InputSystem::handle_button_press(Button & button) {
//checks if the button is a toggle button