commit de merda pa llevar la branch

This commit is contained in:
2025-05-29 12:25:19 +02:00
parent 0fc8224ef8
commit 5fd987c6a1
4 changed files with 60 additions and 53 deletions

View File

@@ -7,10 +7,10 @@
#include "moving_sprite.h"
// Declaraciones adelantadas
// Declaración adelantada
class Texture;
// === Estructura de Animación ===
// Estructura de Animación
struct Animation
{
std::string name; // Nombre de la animación
@@ -24,41 +24,40 @@ struct Animation
Animation() : name(std::string()), speed(5), loop(0), completed(false), current_frame(0), counter(0) {}
};
// === Alias de Tipos ===
// Alias de tipo para buffer de animaciones
using AnimationsFileBuffer = std::vector<std::string>;
// === Funciones Globales ===
// Carga las animaciones desde un fichero en un vector
// Carga las animaciones desde un fichero en un vector de strings
AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path);
// Clase AnimatedSprite: Sprite animado que hereda de MovingSprite
class AnimatedSprite : public MovingSprite
{
public:
// Constructores
// --- Constructores y destructor ---
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path);
AnimatedSprite(std::shared_ptr<Texture> texture, const AnimationsFileBuffer &animations);
explicit AnimatedSprite(std::shared_ptr<Texture> texture) : MovingSprite(texture) {}
virtual ~AnimatedSprite() override = default;
// === Actualización ===
// --- Métodos principales ---
void update() override; // Actualiza la animación
// === Control de Animaciones ===
void setCurrentAnimation(const std::string &name = "default"); // Establecer por nombre
void setCurrentAnimation(int index = 0); // Establecer por índice
void resetAnimation(); // Reiniciar la animación
// --- Control de animaciones ---
void setCurrentAnimation(const std::string &name = "default"); // Establece la animación por nombre
void setCurrentAnimation(int index = 0); // Establece la animación por índice
void resetAnimation(); // Reinicia la animación actual
// === Consultas ===
bool animationIsCompleted(); // Comprobar si ha terminado
int getIndex(const std::string &name); // Obtener índice por nombre
// --- Consultas ---
bool animationIsCompleted(); // Comprueba si la animación ha terminado
int getIndex(const std::string &name); // Obtiene el índice de una animación por nombre
protected:
// === Datos de Animación ===
// --- Datos de animación ---
std::vector<Animation> animations_; // Vector de animaciones disponibles
int current_animation_ = 0; // Índice de la animación activa
// === Métodos Internos ===
void animate(); // Calcular el frame actual de la animación
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source); // Cargar desde buffer
// --- Métodos internos ---
void animate(); // Calcula el frame actual de la animación
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source); // Carga animaciones desde un buffer
};