Implementar Modo DEMO (auto-play) con tecla D

CAMBIOS PRINCIPALES:
-  **Modo DEMO toggleable con tecla D** - Auto-play inteligente
-  **Sistema de acciones aleatorias** - Cada 3-8 segundos
-  **Totalmente interactivo** - Usuario puede seguir controlando
-  **Eliminado sistema auto-restart antiguo** - Ya no reinicia al pararse

CARACTERÍSTICAS DEMO MODE:
- **Acciones parametrizables** con pesos de probabilidad:
  * Cambiar gravedad (UP/DOWN/LEFT/RIGHT) - 15%
  * Activar figuras 3D (8 figuras) - 25%
  * Cambiar temas de colores (6 temas) - 20%
  * Cambiar número de pelotas (1-100K) - 15%
  * Impulsos (SPACE) - 10%
  * Toggle profundidad Z - 5%
  * Cambiar escala de figura - 5%
  * Cambiar sprite - 5%

- **Display visual**: "DEMO MODE" centrado en naranja brillante
- **Textos de feedback**: "DEMO MODE ON/OFF" al togglear

CÓDIGO ELIMINADO:
-  `checkAutoRestart()` y `performRandomRestart()` (ya no necesarios)
-  `Ball::isStopped()` y variable `stopped_` (sin uso)
-  Variables `all_balls_stopped_start_time_`, `all_balls_were_stopped_`

CONSTANTES CONFIGURABLES (defines.h):
- `DEMO_ACTION_INTERVAL_MIN/MAX` (3-8s entre acciones)
- `DEMO_WEIGHT_*` (pesos para priorizar acciones)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-04 11:28:16 +02:00
parent 2ae515592d
commit 06aabc53c0
6 changed files with 184 additions and 59 deletions

View File

@@ -39,7 +39,6 @@ Ball::Ball(float x, float vx, float vy, Color color, std::shared_ptr<Texture> te
screen_width_ = screen_width; // Dimensiones del terreno de juego
screen_height_ = screen_height;
on_surface_ = false;
stopped_ = false;
// Coeficiente base IGUAL para todas las pelotas (solo variación por rebote individual)
loss_ = BASE_BOUNCE_COEFFICIENT; // Coeficiente fijo para todas las pelotas
@@ -56,10 +55,6 @@ Ball::Ball(float x, float vx, float vy, Color color, std::shared_ptr<Texture> te
// Actualiza la lógica de la clase
void Ball::update(float deltaTime) {
if (stopped_) {
return;
}
// Aplica la gravedad según la dirección (píxeles/segundo²)
if (!on_surface_) {
// Aplicar gravedad multiplicada por factor de masa individual
@@ -190,7 +185,6 @@ void Ball::update(float deltaTime) {
vx_ = vx_ * friction_factor;
if (std::fabs(vx_) < 6.0f) {
vx_ = 0.0f;
stopped_ = true;
}
break;
case GravityDirection::LEFT:
@@ -199,7 +193,6 @@ void Ball::update(float deltaTime) {
vy_ = vy_ * friction_factor;
if (std::fabs(vy_) < 6.0f) {
vy_ = 0.0f;
stopped_ = true;
}
break;
}
@@ -220,7 +213,6 @@ void Ball::modVel(float vx, float vy) {
vx_ = vx_ + (vx * 60.0f); // Convertir a píxeles/segundo
vy_ = vy_ + (vy * 60.0f); // Convertir a píxeles/segundo
on_surface_ = false;
stopped_ = false;
}
// Cambia la gravedad (usa la versión convertida)
@@ -249,7 +241,6 @@ void Ball::forceGravityOff() {
void Ball::setGravityDirection(GravityDirection direction) {
gravity_direction_ = direction;
on_surface_ = false; // Ya no está en superficie al cambiar dirección
stopped_ = false; // Reactivar movimiento
}
// Aplica un pequeño empuje lateral aleatorio
@@ -309,7 +300,6 @@ void Ball::enableRotoBallAttraction(bool enable) {
// Al activar atracción, resetear flags de superficie para permitir física completa
if (enable) {
on_surface_ = false;
stopped_ = false;
}
}