revisió de capçaleres

This commit is contained in:
2025-05-29 09:58:23 +02:00
parent 677e4d465d
commit 0fc8224ef8
45 changed files with 1870 additions and 2684 deletions

View File

@@ -1,18 +1,21 @@
#pragma once
#include <SDL3/SDL_rect.h> // Para SDL_FPoint
#include <functional> // Para function
#include <functional> // Para std::function
#include <memory> // Para shared_ptr
#include <vector> // Para vector
#include "sprite.h" // Para Sprite
class Texture; // lines 8-8
class Texture;
// --- Tipos de recorrido ---
enum class PathType
{
VERTICAL,
HORIZONTAL,
};
// --- Centrado del recorrido ---
enum class PathCentered
{
ON_X,
@@ -20,7 +23,7 @@ enum class PathCentered
NONE,
};
// Estructuras
// --- Estructura Path: define un recorrido para el sprite ---
struct Path
{
std::vector<SDL_FPoint> spots; // Puntos por los que se desplazará el sprite
@@ -37,47 +40,39 @@ struct Path
// Devuelve un vector con los puntos que conforman la ruta
std::vector<SDL_FPoint> createPath(float start, float end, PathType type, float fixed_pos, int steps, const std::function<double(double)> &easingFunction);
// Clase PathSprite
// --- Clase PathSprite: Sprite que sigue uno o varios recorridos ---
class PathSprite : public Sprite
{
private:
// Variables
bool enabled_ = false; // Indica si el objeto está habilitado
bool has_finished_ = false; // Indica si el objeto ha finalizado el recorrido
int current_path_ = 0; // Path que se está recorriendo actualmente
std::vector<Path> paths_; // Caminos a recorrer por el sprite
// Coloca el sprite en los diferentes puntos del recorrido
void moveThroughCurrentPath();
// Cambia de recorrido o finaliza
void goToNextPathOrDie();
public:
// Constructor
// --- Constructor y destructor ---
explicit PathSprite(std::shared_ptr<Texture> texture)
: Sprite(texture) {}
// Destructor
~PathSprite() override = default;
// Actualiza la posición del sprite
void update();
// --- Métodos principales ---
void update(); // Actualiza la posición del sprite según el recorrido
void render() override; // Muestra el sprite por pantalla
// Muestra el sprite por pantalla
void render() override;
// --- Gestión de recorridos ---
void addPath(Path path, bool centered = false); // Añade un recorrido (Path)
void addPath(std::vector<SDL_FPoint> spots, int waiting_counter = 0); // Añade un recorrido a partir de puntos
void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter = 0); // Añade un recorrido generado
// Añade un recorrido
void addPath(Path path, bool centered = false);
void addPath(std::vector<SDL_FPoint> spots, int waiting_counter = 0);
void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter = 0);
// --- Estado y control ---
void enable(); // Habilita el objeto
bool hasFinished(); // Indica si ha terminado todos los recorridos
// Habilita el objeto
void enable();
// --- Getters ---
int getCurrentPath() const { return current_path_; } // Devuelve el índice del recorrido actual
// Indica si ha terminado todos los recorridos
bool hasFinished();
private:
// --- Variables internas ---
bool enabled_ = false; // Indica si el objeto está habilitado
bool has_finished_ = false; // Indica si el objeto ha finalizado el recorrido
int current_path_ = 0; // Recorrido que se está recorriendo actualmente
std::vector<Path> paths_; // Caminos a recorrer por el sprite
// Getters
int getCurrentPath() const { return current_path_; }
// --- Métodos internos ---
void moveThroughCurrentPath(); // Coloca el sprite en los diferentes puntos del recorrido
void goToNextPathOrDie(); // Cambia de recorrido o finaliza
};