migrant a SDL3
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL_rect.h> // Para SDL_Rect, SDL_Point
|
||||
#include <SDL3/SDL_rect.h> // Para SDL_FRect, SDL_Point
|
||||
#include <memory> // Para shared_ptr
|
||||
class Texture;
|
||||
|
||||
@@ -10,14 +10,14 @@ class Sprite
|
||||
protected:
|
||||
// Variables
|
||||
std::shared_ptr<Texture> texture_; // Textura donde estan todos los dibujos del sprite
|
||||
SDL_Rect pos_; // Posición y tamaño donde dibujar el sprite
|
||||
SDL_Rect sprite_clip_; // Rectangulo de origen de la textura que se dibujará en pantalla
|
||||
SDL_FRect pos_; // Posición y tamaño donde dibujar el sprite
|
||||
SDL_FRect sprite_clip_; // Rectangulo de origen de la textura que se dibujará en pantalla
|
||||
double zoom_ = 1.0f; // Zoom aplicado a la textura
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Sprite(std::shared_ptr<Texture>, int x, int y, int w, int h);
|
||||
Sprite(std::shared_ptr<Texture>, SDL_Rect rect);
|
||||
Sprite(std::shared_ptr<Texture>, SDL_FRect rect);
|
||||
explicit Sprite(std::shared_ptr<Texture>);
|
||||
|
||||
// Destructor
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
int 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; }
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
// 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(SDL_FRect r) { pos_ = r; }
|
||||
|
||||
// Establece el nivel de zoom
|
||||
void setZoom(float zoom) { zoom_ = zoom; }
|
||||
@@ -58,11 +58,11 @@ public:
|
||||
void incY(int value) { pos_.y += value; }
|
||||
|
||||
// Obtiene el rectangulo que se dibuja de la textura
|
||||
SDL_Rect getSpriteClip() const { return sprite_clip_; }
|
||||
SDL_FRect getSpriteClip() const { return sprite_clip_; }
|
||||
|
||||
// Establece el rectangulo que se dibuja de la textura
|
||||
void setSpriteClip(SDL_Rect rect) { sprite_clip_ = rect; }
|
||||
void setSpriteClip(int x, int y, int w, int h) { sprite_clip_ = (SDL_Rect){x, y, w, h}; }
|
||||
void setSpriteClip(SDL_FRect rect) { sprite_clip_ = rect; }
|
||||
void setSpriteClip(int x, int y, int w, int h) { sprite_clip_ = (SDL_FRect){x, y, w, h}; }
|
||||
|
||||
// Obtiene un puntero a la textura
|
||||
std::shared_ptr<Texture> getTexture() const { return texture_; }
|
||||
|
||||
Reference in New Issue
Block a user