tiled_bg.cpp, afegit changeSpeedTo()
This commit is contained in:
@@ -29,11 +29,13 @@ class TiledBG {
|
||||
|
||||
// --- Configuración ---
|
||||
void setSpeed(float speed) { speed_ = speed; } // Establece la velocidad
|
||||
void changeSpeedTo(float target_speed, float duration_s); // Cambia la velocidad gradualmente en X segundos
|
||||
void stopGracefully() { stopping_ = true; } // Detiene el desplazamiento de forma ordenada
|
||||
void setColor(Color color) { SDL_SetTextureColorMod(canvas_, color.r, color.g, color.b); } // Cambia el color de la textura
|
||||
|
||||
// --- Getters ---
|
||||
[[nodiscard]] auto isStopped() const -> bool { return speed_ == 0.0F; } // Indica si está parado
|
||||
[[nodiscard]] auto isChangingSpeed() const -> bool { return changing_speed_; } // Indica si está cambiando velocidad gradualmente
|
||||
|
||||
private:
|
||||
// --- Constantes ---
|
||||
@@ -56,8 +58,16 @@ class TiledBG {
|
||||
float speed_ = 1.0F; // Incremento que se añade al desplazamiento a cada bucle
|
||||
bool stopping_ = false; // Indica si se está deteniendo
|
||||
|
||||
// --- Variables para cambio gradual de velocidad ---
|
||||
bool changing_speed_ = false; // Indica si está cambiando velocidad gradualmente
|
||||
float initial_speed_ = 0.0F; // Velocidad inicial del cambio
|
||||
float target_speed_ = 0.0F; // Velocidad objetivo del cambio
|
||||
float change_duration_s_ = 0.0F; // Duración total del cambio en segundos
|
||||
float change_timer_s_ = 0.0F; // Tiempo transcurrido del cambio
|
||||
|
||||
// --- Métodos internos ---
|
||||
void fillTexture(); // Rellena la textura con el contenido
|
||||
void updateDesp(float delta_time) { desp_ += speed_ * delta_time; } // Actualiza el desplazamiento (time-based)
|
||||
void updateStop(float delta_time); // Detiene el desplazamiento de forma ordenada (time-based)
|
||||
void updateSpeedChange(float delta_time); // Actualiza el cambio gradual de velocidad (time-based)
|
||||
};
|
||||
Reference in New Issue
Block a user