treball en curs: correccions de tidy

This commit is contained in:
2026-05-16 17:19:40 +02:00
parent 3421f34a84
commit ee2dd0bc2c
30 changed files with 1220 additions and 1479 deletions
+27 -50
View File
@@ -15,7 +15,7 @@ struct Animation {
int speed; // Velocidad de la animación
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
bool completed; // Indica si ha finalizado la animación
int currentFrame; // Frame actual
int current_frame; // Frame actual
int counter; // Contador para las animaciones
};
@@ -25,75 +25,52 @@ struct AnimatedSpriteData {
};
// Carga la animación desde un fichero
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose = false) -> AnimatedSpriteData;
auto loadAnimationFromFile(Texture *texture, const std::string &file_path, bool verbose = false) -> AnimatedSpriteData;
// Carga la animación desde bytes en memoria
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs = "", bool verbose = false) -> AnimatedSpriteData;
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &name_for_logs = "", bool verbose = false) -> AnimatedSpriteData;
class AnimatedSprite : public MovingSprite {
private:
// Variables
std::vector<Animation> animation; // Vector con las diferentes animaciones
int currentAnimation; // Animacion activa
public:
// Constructor
explicit AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, const std::string &file = "", std::vector<std::string> *buffer = nullptr);
AnimatedSprite(SDL_Renderer *renderer, AnimatedSpriteData *animation);
explicit AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, const std::string &file = "", std::vector<std::string> *buffer = nullptr); // Constructor
AnimatedSprite(SDL_Renderer *renderer, AnimatedSpriteData *data);
// Destructor
~AnimatedSprite() override;
~AnimatedSprite() override; // Destructor
// Calcula el frame correspondiente a la animación actual
void animate();
void animate(); // Calcula el frame correspondiente a la animación actual
auto getNumFrames() -> int; // Obtiene el numero de frames de la animación actual
void setCurrentFrame(int num); // Establece el frame actual de la animación
void setAnimationCounter(const std::string &name, int num); // Establece el valor del contador
// Obtiene el numero de frames de la animación actual
auto getNumFrames() -> int;
// Establece el frame actual de la animación
void setCurrentFrame(int num);
// Establece el valor del contador
void setAnimationCounter(const std::string &name, int num);
// Establece la velocidad de una animación
void setAnimationSpeed(const std::string &name, int speed);
void setAnimationSpeed(const std::string &name, int speed); // Establece la velocidad de una animación
void setAnimationSpeed(int index, int speed);
// Establece el frame al que vuelve la animación al finalizar
void setAnimationLoop(const std::string &name, int loop);
void setAnimationLoop(const std::string &name, int loop); // Establece el frame al que vuelve la animación al finalizar
void setAnimationLoop(int index, int loop);
// Establece el valor de la variable
void setAnimationCompleted(const std::string &name, bool value);
void setAnimationCompleted(const std::string &name, bool value); // Establece el valor de la variable
void setAnimationCompleted(int index, bool value);
// Comprueba si ha terminado la animación
auto animationIsCompleted() -> bool;
auto animationIsCompleted() -> bool; // Comprueba si ha terminado la animación
// Devuelve el rectangulo de una animación y frame concreto
auto getAnimationClip(const std::string &name = "default", Uint8 index = 0) -> SDL_Rect;
auto getAnimationClip(int indexA = 0, Uint8 indexF = 0) -> SDL_Rect;
auto getAnimationClip(const std::string &name = "default", Uint8 index = 0) -> SDL_Rect; // Devuelve el rectangulo de una animación y frame concreto
auto getAnimationClip(int index_a = 0, Uint8 index_f = 0) -> SDL_Rect;
// Obtiene el indice de la animación a partir del nombre
auto getIndex(const std::string &name) -> int;
auto getIndex(const std::string &name) -> int; // Obtiene el indice de la animación a partir del nombre
auto loadFromVector(std::vector<std::string> *source) -> bool; // Carga la animación desde un vector
// Carga la animación desde un vector
auto loadFromVector(std::vector<std::string> *source) -> bool;
// Establece la animacion actual
void setCurrentAnimation(const std::string &name = "default");
void setCurrentAnimation(const std::string &name = "default"); // Establece la animacion actual
void setCurrentAnimation(int index = 0);
// Actualiza las variables del objeto
void update() override;
void update() override; // Actualiza las variables del objeto
// OLD - Establece el rectangulo para un frame de una animación
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h); // OLD - Establece el rectangulo para un frame de una animación
void setAnimationCounter(int value); // OLD - Establece el contador para todas las animaciones
// OLD - Establece el contador para todas las animaciones
void setAnimationCounter(int value);
void resetAnimation(); // Reinicia la animación
// Reinicia la animación
void resetAnimation();
private:
// Variables
std::vector<Animation> animation_; // Vector con las diferentes animaciones
int current_animation_; // Animacion activa
};