feat: Convertir BOIDS a sistema time-based (independiente de framerate)
- Conversión completa de físicas BOIDS de frame-based a time-based - Velocidades: ×60 (px/frame → px/s) - Aceleraciones (Separation, Cohesion): ×3600 (px/frame² → px/s²) - Steering proporcional (Alignment): ×60 - Límites de velocidad: ×60 Constantes actualizadas en defines.h: - BOID_SEPARATION_WEIGHT: 1.5 → 5400.0 (aceleración) - BOID_COHESION_WEIGHT: 0.001 → 3.6 (aceleración) - BOID_ALIGNMENT_WEIGHT: 1.0 → 60.0 (steering) - BOID_MAX_SPEED: 2.5 → 150.0 px/s - BOID_MIN_SPEED: 0.3 → 18.0 px/s - BOID_MAX_FORCE: 0.05 → 3.0 px/s Física ahora consistente en 60Hz, 144Hz, 240Hz screens. Transiciones BOIDS↔PHYSICS preservan velocidad correctamente. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -57,9 +57,9 @@ void BoidManager::activateBoids() {
|
||||
float vx, vy;
|
||||
ball->getVelocity(vx, vy);
|
||||
if (vx == 0.0f && vy == 0.0f) {
|
||||
// Velocidad aleatoria entre -1 y 1
|
||||
vx = (rand() % 200 - 100) / 100.0f;
|
||||
vy = (rand() % 200 - 100) / 100.0f;
|
||||
// Velocidad aleatoria entre -60 y +60 px/s (time-based)
|
||||
vx = ((rand() % 200 - 100) / 100.0f) * 60.0f;
|
||||
vy = ((rand() % 200 - 100) / 100.0f) * 60.0f;
|
||||
ball->setVelocity(vx, vy);
|
||||
}
|
||||
}
|
||||
@@ -118,14 +118,14 @@ void BoidManager::update(float delta_time) {
|
||||
limitSpeed(ball.get());
|
||||
}
|
||||
|
||||
// Actualizar posiciones con velocidades resultantes
|
||||
// Actualizar posiciones con velocidades resultantes (time-based)
|
||||
for (auto& ball : balls) {
|
||||
float vx, vy;
|
||||
ball->getVelocity(vx, vy);
|
||||
|
||||
SDL_FRect pos = ball->getPosition();
|
||||
pos.x += vx;
|
||||
pos.y += vy;
|
||||
pos.x += vx * delta_time; // time-based
|
||||
pos.y += vy * delta_time;
|
||||
|
||||
ball->setPosition(pos.x, pos.y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user