corregides cridades a SDL3 i migrat casi tot de int a float. Falta jail_shader

This commit is contained in:
2025-10-15 12:16:50 +02:00
parent 7c102e42cc
commit e4a08d2ec7
52 changed files with 879 additions and 823 deletions

View File

@@ -190,7 +190,7 @@ void SAnimatedSprite::setAnimations(const Animations& animations) {
// Se introducen los valores separados por comas en un vector
std::stringstream ss(value);
std::string tmp;
SDL_Rect rect = {0, 0, frame_width, frame_height};
SDL_FRect rect = {0, 0, frame_width, frame_height};
while (getline(ss, tmp, ',')) {
// Comprueba que el tile no sea mayor que el maximo indice permitido
const int num_tile = std::stoi(tmp);

View File

@@ -10,13 +10,13 @@
class Surface; // lines 9-9
struct AnimationData {
std::string name; // Nombre de la animacion
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
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 current_frame; // Frame actual
int counter; // Contador para las animaciones
std::string name; // Nombre de la animacion
std::vector<SDL_FRect> frames; // Cada uno de los frames que componen la animación
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 current_frame; // Frame actual
int counter; // Contador para las animaciones
AnimationData()
: name(std::string()),

View File

@@ -3,13 +3,13 @@
#include "surface.h" // Para Surface
// Constructor
SMovingSprite::SMovingSprite(std::shared_ptr<Surface> surface, SDL_Rect pos, SDL_RendererFlip flip)
SMovingSprite::SMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip)
: SSprite(surface, pos),
x_(pos.x),
y_(pos.y),
flip_(flip) { SSprite::pos_ = pos; }
SMovingSprite::SMovingSprite(std::shared_ptr<Surface> surface, SDL_Rect pos)
SMovingSprite::SMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
: SSprite(surface, pos),
x_(pos.x),
y_(pos.y),
@@ -65,7 +65,7 @@ void SMovingSprite::render(Uint8 source_color, Uint8 target_color) {
}
// Establece la posición y_ el tamaño del objeto
void SMovingSprite::setPos(SDL_Rect rect) {
void SMovingSprite::setPos(SDL_FRect rect) {
x_ = static_cast<float>(rect.x);
y_ = static_cast<float>(rect.y);

View File

@@ -20,15 +20,15 @@ class SMovingSprite : public SSprite {
float ax_ = 0.0f; // Aceleración en el eje X. Variación de la velocidad
float ay_ = 0.0f; // Aceleración en el eje Y. Variación de la velocidad
SDL_RendererFlip flip_; // Indica como se voltea el sprite
SDL_FlipMode flip_; // Indica como se voltea el sprite
// Mueve el sprite
void move();
public:
// Constructor
SMovingSprite(std::shared_ptr<Surface> surface, SDL_Rect pos, SDL_RendererFlip flip);
SMovingSprite(std::shared_ptr<Surface> surface, SDL_Rect pos);
SMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip);
SMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
explicit SMovingSprite(std::shared_ptr<Surface> surface);
// Destructor
@@ -59,16 +59,16 @@ class SMovingSprite : public SSprite {
void setAccelY(float value) { ay_ = value; }
// Establece el valor de la variable
void setFlip(SDL_RendererFlip flip) { flip_ = flip; }
void setFlip(SDL_FlipMode flip) { flip_ = flip; }
// Gira el sprite horizontalmente
void flip() { flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; }
// Obtiene el valor de la variable
SDL_RendererFlip getFlip() { return flip_; }
SDL_FlipMode getFlip() { return flip_; }
// Establece la posición y_ el tamaño del objeto
void setPos(SDL_Rect rect);
void setPos(SDL_FRect rect);
// Establece el valor de las variables
void setPos(float x, float y);

View File

@@ -3,19 +3,19 @@
#include "surface.h" // Para Surface
// Constructor
SSprite::SSprite(std::shared_ptr<Surface> surface, int x, int y, int w, int h)
SSprite::SSprite(std::shared_ptr<Surface> surface, float x, float y, float w, float h)
: surface_(surface),
pos_((SDL_Rect){x, y, w, h}),
clip_((SDL_Rect){0, 0, pos_.w, pos_.h}) {}
pos_((SDL_FRect){x, y, w, h}),
clip_((SDL_FRect){0.0F, 0.0F, pos_.w, pos_.h}) {}
SSprite::SSprite(std::shared_ptr<Surface> surface, SDL_Rect rect)
SSprite::SSprite(std::shared_ptr<Surface> surface, SDL_FRect rect)
: surface_(surface),
pos_(rect),
clip_((SDL_Rect){0, 0, pos_.w, pos_.h}) {}
clip_((SDL_FRect){0, 0, pos_.w, pos_.h}) {}
SSprite::SSprite(std::shared_ptr<Surface> surface)
: surface_(surface),
pos_({0, 0, surface_->getWidth(), surface_->getHeight()}),
pos_((SDL_FRect){0.0F, 0.0F, surface_->getWidth(), surface_->getHeight()}),
clip_(pos_) {}
// Muestra el sprite por pantalla
@@ -28,13 +28,13 @@ void SSprite::render(Uint8 source_color, Uint8 target_color) {
}
// Establece la posición del objeto
void SSprite::setPosition(int x, int y) {
void SSprite::setPosition(float x, float y) {
pos_.x = x;
pos_.y = y;
}
// Establece la posición del objeto
void SSprite::setPosition(SDL_Point p) {
void SSprite::setPosition(SDL_FPoint p) {
pos_.x = p.x;
pos_.y = p.y;
}

View File

@@ -10,13 +10,13 @@ class SSprite {
protected:
// Variables
std::shared_ptr<Surface> surface_; // Surface donde estan todos los dibujos del sprite
SDL_Rect pos_; // Posición y tamaño donde dibujar el sprite
SDL_Rect clip_; // Rectangulo de origen de la surface que se dibujará en pantalla
SDL_FRect pos_; // Posición y tamaño donde dibujar el sprite
SDL_FRect clip_; // Rectangulo de origen de la surface que se dibujará en pantalla
public:
// Constructor
SSprite(std::shared_ptr<Surface>, int x, int y, int w, int h);
SSprite(std::shared_ptr<Surface>, SDL_Rect rect);
SSprite(std::shared_ptr<Surface>, float x, float y, float w, float h);
SSprite(std::shared_ptr<Surface>, SDL_FRect rect);
explicit SSprite(std::shared_ptr<Surface>);
// Destructor
@@ -30,36 +30,36 @@ class SSprite {
virtual void clear();
// Obtiene la posición y el tamaño
int getX() const { return pos_.x; }
int getY() const { return pos_.y; }
int getWidth() const { return pos_.w; }
int getHeight() const { return pos_.h; }
float getX() const { return pos_.x; }
float getY() const { return pos_.y; }
float getWidth() const { return pos_.w; }
float getHeight() const { return pos_.h; }
// Devuelve el rectangulo donde está el sprite
SDL_Rect getPosition() const { return pos_; }
SDL_Rect& getRect() { return pos_; }
SDL_FRect getPosition() const { return pos_; }
SDL_FRect& getRect() { return pos_; }
// Establece la posición y el tamaño
void setX(int x) { pos_.x = x; }
void setY(int y) { pos_.y = y; }
void setWidth(int w) { pos_.w = w; }
void setHeight(int h) { pos_.h = h; }
void setX(float x) { pos_.x = x; }
void setY(float y) { pos_.y = y; }
void setWidth(float w) { pos_.w = w; }
void setHeight(float h) { pos_.h = h; }
// Establece la posición del objeto
void setPosition(int x, int y);
void setPosition(SDL_Point p);
void setPosition(SDL_Rect r) { pos_ = r; }
void setPosition(float x, float y);
void setPosition(SDL_FPoint p);
void setPosition(SDL_FRect r) { pos_ = r; }
// Aumenta o disminuye la posición
void incX(int value) { pos_.x += value; }
void incY(int value) { pos_.y += value; }
void incX(float value) { pos_.x += value; }
void incY(float value) { pos_.y += value; }
// Obtiene el rectangulo que se dibuja de la surface
SDL_Rect getClip() const { return clip_; }
SDL_FRect getClip() const { return clip_; }
// Establece el rectangulo que se dibuja de la surface
void setClip(SDL_Rect rect) { clip_ = rect; }
void setClip(int x, int y, int w, int h) { clip_ = (SDL_Rect){x, y, w, h}; }
void setClip(SDL_FRect rect) { clip_ = rect; }
void setClip(float x, float y, float w, float h) { clip_ = (SDL_FRect){x, y, w, h}; }
// Obtiene un puntero a la surface
std::shared_ptr<Surface> getSurface() const { return surface_; }