forked from jaildesigner-jailgames/jaildoctors_dilemma
eliminats metodes deprecated
migracions finals a time based migracions de jail_audio a Audio
This commit is contained in:
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user