#pragma once #include // Para SDL_FRect, SDL_FPoint #include // Para shared_ptr class Texture; // Clase Sprite: representa un objeto gráfico básico con posición, tamaño y textura class Sprite { public: // --- Constructores y destructor --- Sprite(std::shared_ptr texture, float x, float y, float w, float h); Sprite(std::shared_ptr texture, SDL_FRect rect); explicit Sprite(std::shared_ptr texture); virtual ~Sprite() = default; // --- Renderizado y control --- virtual void render(); // Muestra el sprite por pantalla virtual void clear(); // Reinicia las variables a cero // --- Getters de posición y 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; } SDL_FRect getPosition() const { return pos_; } SDL_FRect &getRect() { return pos_; } // --- Setters de posición y tamaño --- 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; } void setPosition(float x, float y); void setPosition(SDL_FPoint p); void setPosition(SDL_FRect r) { pos_ = r; } // --- Zoom --- void setZoom(float zoom) { zoom_ = zoom; } // --- Modificación de posición --- void incX(float value) { pos_.x += value; } void incY(float value) { pos_.y += value; } // --- Sprite clip --- SDL_FRect getSpriteClip() const { return sprite_clip_; } void setSpriteClip(SDL_FRect rect) { sprite_clip_ = rect; } void setSpriteClip(float x, float y, float w, float h) { sprite_clip_ = SDL_FRect{x, y, w, h}; } // --- Textura --- std::shared_ptr getTexture() const { return texture_; } void setTexture(std::shared_ptr texture) { texture_ = texture; } protected: // --- Variables internas --- std::shared_ptr texture_; // Textura donde están todos los dibujos del sprite SDL_FRect pos_; // Posición y tamaño donde dibujar el sprite SDL_FRect sprite_clip_; // Rectángulo de origen de la textura que se dibujará en pantalla double zoom_ = 1.0f; // Zoom aplicado a la textura };