diff --git a/source/ball.cpp b/source/ball.cpp index 647bb7b..7f271dc 100644 --- a/source/ball.cpp +++ b/source/ball.cpp @@ -7,11 +7,11 @@ #include "defines.h" // for BALL_SIZE, Color, SCREEN_HEIGHT, GRAVITY_FORCE class Texture; -// Función auxiliar para generar variación aleatoria en rebotes +// Función auxiliar para generar pérdida aleatoria en rebotes float generateBounceVariation() { - // Genera un valor entre -BOUNCE_VARIATION_PERCENT y +BOUNCE_VARIATION_PERCENT - float variation = ((rand() % 1000) / 1000.0f - 0.5f) * 2.0f * BOUNCE_VARIATION_PERCENT; - return 1.0f + variation; // Retorna multiplicador (ej: 0.95 - 1.05 para ±5%) + // Genera un valor entre 0 y BOUNCE_RANDOM_LOSS_PERCENT (solo pérdida adicional) + float loss = (rand() % 1000) / 1000.0f * BOUNCE_RANDOM_LOSS_PERCENT; + return 1.0f - loss; // Retorna multiplicador (ej: 0.90 - 1.00 para 10% max pérdida) } // Función auxiliar para generar pérdida lateral aleatoria diff --git a/source/defines.h b/source/defines.h index dc5849a..09e80dd 100644 --- a/source/defines.h +++ b/source/defines.h @@ -11,9 +11,9 @@ constexpr float GRAVITY_FORCE = 0.2f; // DEMO_SPEED eliminado - ya no se usa con delta time constexpr Uint64 TEXT_DURATION = 2000; -// Configuración de variación aleatoria en rebotes +// Configuración de pérdida aleatoria en rebotes constexpr float BASE_BOUNCE_COEFFICIENT = 0.75f; // Coeficiente base IGUAL para todas las pelotas -constexpr float BOUNCE_VARIATION_PERCENT = 0.05f; // ±5% variación en cada rebote +constexpr float BOUNCE_RANDOM_LOSS_PERCENT = 0.1f; // 0-10% pérdida adicional aleatoria en cada rebote constexpr float LATERAL_LOSS_PERCENT = 0.02f; // ±2% pérdida lateral en rebotes struct Color {