This commit is contained in:
2025-10-27 18:35:53 +01:00
parent b1dca32a5b
commit 3179a08dac
63 changed files with 686 additions and 693 deletions
+11 -10
View File
@@ -3,7 +3,8 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
class Surface; // lines 5-5
#include <utility>
class Surface; // lines 5-5
// Clase SurfaceSprite
class SurfaceSprite {
@@ -30,14 +31,14 @@ class SurfaceSprite {
virtual void clear();
// Obtiene la posición y el tamaño
float getX() const { return pos_.x; }
float getY() const { return pos_.y; }
float getWidth() const { return pos_.w; }
float getHeight() const { return pos_.h; }
[[nodiscard]] auto getX() const -> float { return pos_.x; }
[[nodiscard]] auto getY() const -> float { return pos_.y; }
[[nodiscard]] auto getWidth() const -> float { return pos_.w; }
[[nodiscard]] auto getHeight() const -> float { return pos_.h; }
// Devuelve el rectangulo donde está el sprite
SDL_FRect getPosition() const { return pos_; }
SDL_FRect& getRect() { return pos_; }
[[nodiscard]] auto getPosition() const -> SDL_FRect { return pos_; }
auto getRect() -> SDL_FRect& { return pos_; }
// Establece la posición y el tamaño
void setX(float x) { pos_.x = x; }
@@ -55,15 +56,15 @@ class SurfaceSprite {
void incY(float value) { pos_.y += value; }
// Obtiene el rectangulo que se dibuja de la surface
SDL_FRect getClip() const { return clip_; }
[[nodiscard]] auto getClip() const -> SDL_FRect { return clip_; }
// Establece el rectangulo que se dibuja de la surface
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_; }
[[nodiscard]] auto getSurface() const -> std::shared_ptr<Surface> { return surface_; }
// Establece la surface a utilizar
void setSurface(std::shared_ptr<Surface> surface) { surface_ = surface; }
void setSurface(std::shared_ptr<Surface> surface) { surface_ = std::move(surface); }
};