eliminats metodes deprecated

migracions finals a time based
migracions de jail_audio a Audio
This commit is contained in:
2025-10-31 10:32:23 +01:00
parent 1bb3d00e7c
commit 2f20ac422e
15 changed files with 50 additions and 136 deletions

View File

@@ -89,13 +89,20 @@ void Audio::stopMusic() {
}
}
// Reproduce un sonido
// Reproduce un sonido por nombre
void Audio::playSound(const std::string& name, Group group) const {
if (sound_enabled_) {
JA_PlaySound(Resource::get()->getSound(name), 0, static_cast<int>(group));
}
}
// Reproduce un sonido por puntero directo
void Audio::playSound(JA_Sound_t* sound, Group group) const {
if (sound_enabled_) {
JA_PlaySound(sound, 0, static_cast<int>(group));
}
}
// Detiene todos los sonidos
void Audio::stopAllSounds() const {
if (sound_enabled_) {

View File

@@ -42,8 +42,9 @@ class Audio {
void fadeOutMusic(int milliseconds) const; // Fundido de salida de la música
// --- Control de Sonidos ---
void playSound(const std::string& name, Group group = Group::GAME) const; // Reproducir sonido puntual
void stopAllSounds() const; // Detener todos los sonidos
void playSound(const std::string& name, Group group = Group::GAME) const; // Reproducir sonido puntual por nombre
void playSound(struct JA_Sound_t* sound, Group group = Group::GAME) const; // Reproducir sonido puntual por puntero
void stopAllSounds() const; // Detener todos los sonidos
// --- Configuración General ---
void enable(bool value); // Establecer estado general

View File

@@ -133,38 +133,6 @@ void SurfaceAnimatedSprite::animate(float delta_time) {
}
}
// Calcula el frame correspondiente a la animación (frame-based, deprecated)
void SurfaceAnimatedSprite::animate() {
if (animations_[current_animation_].speed == 0.0F) {
return;
}
// Calcula el frame actual a partir del contador (sistema antiguo)
animations_[current_animation_].current_frame =
static_cast<int>(animations_[current_animation_].counter / animations_[current_animation_].speed);
// Si alcanza el final de la animación, reinicia el contador de la animación
// en función de la variable loop y coloca el nuevo frame
if (animations_[current_animation_].current_frame >= static_cast<int>(animations_[current_animation_].frames.size())) {
if (animations_[current_animation_].loop == -1) { // Si no hay loop, deja el último frame
animations_[current_animation_].current_frame =
static_cast<int>(animations_[current_animation_].frames.size()) - 1;
animations_[current_animation_].completed = true;
} else { // Si hay loop, vuelve al frame indicado
animations_[current_animation_].counter = 0;
animations_[current_animation_].current_frame = animations_[current_animation_].loop;
}
}
// En caso contrario
else {
// Escoge el frame correspondiente de la animación
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
// Incrementa el contador de la animacion
animations_[current_animation_].counter++;
}
}
// Comprueba si ha terminado la animación
auto SurfaceAnimatedSprite::animationIsCompleted() -> bool {
return animations_[current_animation_].completed;
@@ -176,8 +144,7 @@ void SurfaceAnimatedSprite::setCurrentAnimation(const std::string& name) {
if (current_animation_ != NEW_ANIMATION) {
current_animation_ = NEW_ANIMATION;
animations_[current_animation_].current_frame = 0;
animations_[current_animation_].accumulated_time = 0.0F; // Time-based
animations_[current_animation_].counter = 0; // Frame-based (deprecated)
animations_[current_animation_].accumulated_time = 0.0F;
animations_[current_animation_].completed = false;
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
}
@@ -189,8 +156,7 @@ void SurfaceAnimatedSprite::setCurrentAnimation(int index) {
if (current_animation_ != NEW_ANIMATION) {
current_animation_ = NEW_ANIMATION;
animations_[current_animation_].current_frame = 0;
animations_[current_animation_].accumulated_time = 0.0F; // Time-based
animations_[current_animation_].counter = 0; // Frame-based (deprecated)
animations_[current_animation_].accumulated_time = 0.0F;
animations_[current_animation_].completed = false;
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
}
@@ -202,17 +168,10 @@ void SurfaceAnimatedSprite::update(float delta_time) {
SurfaceMovingSprite::update(delta_time);
}
// Actualiza las variables del objeto (frame-based, deprecated)
void SurfaceAnimatedSprite::update() {
animate();
SurfaceMovingSprite::update();
}
// Reinicia la animación
void SurfaceAnimatedSprite::resetAnimation() {
animations_[current_animation_].current_frame = 0;
animations_[current_animation_].accumulated_time = 0.0F; // Time-based
animations_[current_animation_].counter = 0; // Frame-based (deprecated)
animations_[current_animation_].accumulated_time = 0.0F;
animations_[current_animation_].completed = false;
}
@@ -356,7 +315,6 @@ void SurfaceAnimatedSprite::setCurrentAnimationFrame(int num) {
// Cambia el valor de la variable
animations_[current_animation_].current_frame = num;
animations_[current_animation_].counter = 0;
// Escoge el frame correspondiente de la animación
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);

View File

@@ -19,9 +19,6 @@ struct AnimationData {
int current_frame{0}; // Frame actual
float accumulated_time{0.0F}; // Tiempo acumulado para las animaciones (time-based)
// DEPRECATED: Mantener compatibilidad con sistema antiguo
int counter{0}; // Contador para las animaciones (frame-based, deprecated)
AnimationData()
= default;
@@ -41,9 +38,6 @@ class SurfaceAnimatedSprite : public SurfaceMovingSprite {
// Calcula el frame correspondiente a la animación actual (time-based)
void animate(float delta_time);
// Calcula el frame correspondiente a la animación actual (frame-based, deprecated)
void animate();
// Carga la animación desde un vector de cadenas
void setAnimations(const Animations& animations);
@@ -66,10 +60,6 @@ class SurfaceAnimatedSprite : public SurfaceMovingSprite {
// Actualiza las variables del objeto (time-based)
void update(float delta_time) override;
// Actualiza las variables del objeto (frame-based, deprecated)
[[deprecated("Use update(float delta_time) instead")]]
void update() override;
// Comprueba si ha terminado la animación
auto animationIsCompleted() -> bool;

View File

@@ -62,29 +62,11 @@ void SurfaceMovingSprite::move(float delta_time) {
pos_.y = static_cast<int>(y_);
}
// Mueve el sprite (frame-based, deprecated)
void SurfaceMovingSprite::move() {
// Versión antigua: suma directa sin delta_time
x_ += vx_;
y_ += vy_;
vx_ += ax_;
vy_ += ay_;
pos_.x = static_cast<int>(x_);
pos_.y = static_cast<int>(y_);
}
// Actualiza las variables internas del objeto (time-based)
void SurfaceMovingSprite::update(float delta_time) {
move(delta_time);
}
// Actualiza las variables internas del objeto (frame-based, deprecated)
void SurfaceMovingSprite::update() {
move();
}
// Muestra el sprite por pantalla
void SurfaceMovingSprite::render() {
surface_->render(pos_.x, pos_.y, &clip_, flip_);

View File

@@ -25,9 +25,6 @@ class SurfaceMovingSprite : public SurfaceSprite {
// Mueve el sprite (time-based)
void move(float delta_time);
// Mueve el sprite (frame-based, deprecated)
void move();
public:
// Constructor
SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip);
@@ -41,10 +38,6 @@ class SurfaceMovingSprite : public SurfaceSprite {
// Actualiza las variables internas del objeto (time-based)
void update(float delta_time) override;
// Actualiza las variables internas del objeto (frame-based, deprecated)
[[deprecated("Use update(float delta_time) instead")]]
void update() override;
// Reinicia todas las variables a cero
void clear() override;

View File

@@ -55,10 +55,4 @@ void SurfaceSprite::clear() {
void SurfaceSprite::update(float delta_time) {
// Base implementation does nothing (static sprites)
(void)delta_time; // Evita warning de parámetro no usado
}
// Actualiza el estado del sprite (frame-based, deprecated)
void SurfaceSprite::update() {
// Llama a la versión time-based con 0.0f para compatibilidad
update(0.0F);
}

View File

@@ -27,10 +27,6 @@ class SurfaceSprite {
// Actualiza el estado del sprite (time-based)
virtual void update(float delta_time);
// Actualiza el estado del sprite (frame-based, deprecated)
[[deprecated("Use update(float delta_time) instead")]]
virtual void update();
// Muestra el sprite por pantalla
virtual void render();
virtual void render(Uint8 source_color, Uint8 target_color);