Pasaeta de include-what-you-use

Acabada de perfilar la classe PathSprite
Menjeades declaracions de utils.h als fitxers que toca
This commit is contained in:
2024-10-28 20:45:24 +01:00
parent 0fe371653a
commit 787cb6366f
55 changed files with 768 additions and 805 deletions

View File

@@ -1,8 +1,11 @@
#pragma once
#include <memory> // para shared_ptr
#include "animated_sprite.h" // para SpriteAnimated
class Texture;
#include <SDL2/SDL_rect.h> // Para SDL_Point
#include <memory> // Para shared_ptr
#include <functional>
#include <vector> // Para vector
#include "animated_sprite.h" // Para AnimatedSprite
class Texture; // lines 5-5
enum class PathType
{
@@ -15,20 +18,18 @@ class PathSprite : public AnimatedSprite
{
private:
// Estructuras
struct Path {
std::vector<SDL_Point> spots; // Puntos por los que se desplazará el sprite
int fixed_pos; // Coordenada fija
int waiting_counter; // Tiempo de espera una vez en el destino
bool on_destination = false; // Indica si ha llegado al destino
bool finished = false; // Indica si ha terminado de esperarse
int counter = 0; // Contador interno
PathType type; // Tipo de recorrido
// Constructor
Path(const std::vector<SDL_Point>& spots_init, int waiting_counter_init, int fixed_pos_init, PathType type_init)
: spots(spots_init), waiting_counter(waiting_counter_init), fixed_pos(fixed_pos_init), type(type_init) {}
};
struct Path
{
std::vector<SDL_Point> spots; // Puntos por los que se desplazará el sprite
int waiting_counter; // Tiempo de espera una vez en el destino
bool on_destination = false; // Indica si ha llegado al destino
bool finished = false; // Indica si ha terminado de esperarse
int counter = 0; // Contador interno
// Constructor
Path(const std::vector<SDL_Point> &spots_init, int waiting_counter_init)
: spots(spots_init), waiting_counter(waiting_counter_init) {}
};
// Variables
bool finished_ = false; // Indica si ya ha terminado
@@ -52,20 +53,12 @@ public:
// Actualiza la posición del sprite
void update() override;
// Añade un recorrido vertical
void addVerticalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter);
// Añade un recorrido horizontal
void addHorizontalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter);
// Añade un recorrido desde un vector
// Añade un recorrido
void addPath(std::vector<SDL_Point> spots, int waiting_counter);
void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter);
// Devuelve un vector con los puntos que conforman la ruta
std::vector<SDL_Point> createVerticalPath(const SDL_Point &start, const SDL_Point &end, int steps);
// Devuelve un vector con los puntos que conforman la ruta
std::vector<SDL_Point> createHorizontalPath(SDL_Point start, SDL_Point end, int steps);
std::vector<SDL_Point> createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction);
// Habilita el objeto
void enable();