precarrega les textures del jugador amb variants de paleta

This commit is contained in:
2025-08-10 19:36:10 +02:00
parent 72e606f6d3
commit 645862ecb5
11 changed files with 132 additions and 66 deletions

View File

@@ -3,6 +3,7 @@
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_FPoint
#include <memory> // Para shared_ptr
#include <vector> // Para vector
class Texture;
@@ -49,13 +50,22 @@ class Sprite {
void setSpriteClip(float pos_x, float pos_y, float width, float height) { sprite_clip_ = SDL_FRect{pos_x, pos_y, width, height}; }
// --- Textura ---
[[nodiscard]] auto getTexture() const -> std::shared_ptr<Texture> { return texture_; }
void setTexture(std::shared_ptr<Texture> texture) { texture_ = texture; }
[[nodiscard]] auto getTexture() const -> std::shared_ptr<Texture> { return textures_.at(texture_index_); }
void setTexture(std::shared_ptr<Texture> texture) { textures_.at(texture_index_) = texture; }
void addTexture(std::shared_ptr<Texture> texture) { textures_.push_back(texture); }
bool setActiveTexture(size_t index); // Cambia la textura activa por índice
size_t getActiveTextureIndex() const { return texture_index_; } // Obtiene el índice de la textura activa
size_t getTextureCount() const { return textures_.size(); } // Obtiene el número total de texturas
protected:
std::shared_ptr<Texture>& getTextureRef() {
return textures_.at(texture_index_);
}
// --- Variables internas ---
std::shared_ptr<Texture> 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
size_t texture_index_ = 0;
std::vector<std::shared_ptr<Texture>> textures_; // Lista de texturas
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
};