retocada aceleració de drag'n drop
This commit is contained in:
@@ -492,12 +492,20 @@ void Game::handleDebugMouseDrag(float delta_time) {
|
|||||||
float dy = game_y - player_y;
|
float dy = game_y - player_y;
|
||||||
float distance = std::sqrt(dx * dx + dy * dy);
|
float distance = std::sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
// Velocidad de movimiento hacia el cursor (pixels/segundo)
|
// Constantes de velocidad con ease-in (aceleración progresiva)
|
||||||
constexpr float DRAG_SPEED = 300.0F;
|
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) {
|
if (distance > 1.0F) {
|
||||||
// Calcular el movimiento con aceleración (interpolación suave)
|
// Calcular el movimiento con la velocidad actual
|
||||||
float move_factor = std::min(1.0F, DRAG_SPEED * delta_time / distance);
|
float move_factor = std::min(1.0F, debug_drag_speed_ * delta_time / distance);
|
||||||
float new_x = player_x + dx * move_factor;
|
float new_x = player_x + dx * move_factor;
|
||||||
float new_y = player_y + dy * 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
|
// Botón soltado después de arrastrar: finalizar teleport
|
||||||
player_->finalizeDebugTeleport();
|
player_->finalizeDebugTeleport();
|
||||||
debug_dragging_player_ = false;
|
debug_dragging_player_ = false;
|
||||||
|
debug_drag_speed_ = 0.0F; // Reset para el próximo arrastre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -130,5 +130,6 @@ class Game {
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Variables de debug para arrastre con ratón
|
// Variables de debug para arrastre con ratón
|
||||||
bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el 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
|
#endif
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user