#include "ui.h" #include "game.h" #include #include #include static bool is_dragging; static Vector2 drag_start_pos; void handle_mouse_input(GameState_t *game_state) { if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { drag_start_pos = GetMousePosition(); if (drag_start_pos.x >= 500 && drag_start_pos.x <= 775 && drag_start_pos.y >= 455 && drag_start_pos.y <= 479) { reset_board(game_state); return; } is_dragging = true; } else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON) && is_dragging) { Vector2 current_pos = GetMousePosition(); float dx = current_pos.x - drag_start_pos.x; float dy = current_pos.y - drag_start_pos.y; float drag_distance = sqrt(dx * dx + dy * dy); // We don't want to register single clicks as a move if (drag_distance >= 30) { if (fabs(dx) > fabs(dy)) { if (dx > 0) { move(game_state, RIGHT); } else { move(game_state, LEFT); } } else { if (dy > 0) { move(game_state, DOWN); } else { move(game_state, UP); } } spawn_tile(game_state); } is_dragging = false; } }