From bd011a0ebbd86de74749da86e3c21ed9654e738b Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 21 Nov 2025 23:21:29 +0100 Subject: [PATCH] =?UTF-8?q?retocada=20aceleraci=C3=B3=20de=20drag'n=20drop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/game/scenes/game.cpp | 17 +++++++++++++---- source/game/scenes/game.hpp | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index f1abde76..c5b83f50 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -492,12 +492,20 @@ void Game::handleDebugMouseDrag(float delta_time) { float dy = game_y - player_y; float distance = std::sqrt(dx * dx + dy * dy); - // Velocidad de movimiento hacia el cursor (pixels/segundo) - constexpr float DRAG_SPEED = 300.0F; + // Constantes de velocidad con ease-in (aceleración progresiva) + constexpr float DRAG_SPEED_MIN = 30.0F; // Velocidad inicial (pixels/segundo) + constexpr float DRAG_SPEED_MAX = 600.0F; // Velocidad máxima (pixels/segundo) + constexpr float DRAG_ACCELERATION = 600.0F; // Aceleración (pixels/segundo²) + + // Incrementar velocidad con el tiempo (ease-in) + if (!debug_dragging_player_) { + debug_drag_speed_ = DRAG_SPEED_MIN; // Iniciar con velocidad mínima + } + debug_drag_speed_ = std::min(DRAG_SPEED_MAX, debug_drag_speed_ + DRAG_ACCELERATION * delta_time); if (distance > 1.0F) { - // Calcular el movimiento con aceleración (interpolación suave) - float move_factor = std::min(1.0F, DRAG_SPEED * delta_time / distance); + // Calcular el movimiento con la velocidad actual + float move_factor = std::min(1.0F, debug_drag_speed_ * delta_time / distance); float new_x = player_x + dx * move_factor; float new_y = player_y + dy * move_factor; @@ -512,6 +520,7 @@ void Game::handleDebugMouseDrag(float delta_time) { // Botón soltado después de arrastrar: finalizar teleport player_->finalizeDebugTeleport(); debug_dragging_player_ = false; + debug_drag_speed_ = 0.0F; // Reset para el próximo arrastre } } #endif diff --git a/source/game/scenes/game.hpp b/source/game/scenes/game.hpp index b6f56834..f30e04a9 100644 --- a/source/game/scenes/game.hpp +++ b/source/game/scenes/game.hpp @@ -130,5 +130,6 @@ class Game { #ifdef _DEBUG // Variables de debug para arrastre con ratón bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el ratón + float debug_drag_speed_{0.0F}; // Velocidad actual del arrastre (ease-in) #endif }; \ No newline at end of file