clang-tidy readability-function-cognitive-complexity
clang-format
This commit is contained in:
@@ -8,54 +8,54 @@ 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> texture, float pos_x, float pos_y, float width, float height);
|
||||
Sprite(std::shared_ptr<Texture> texture, SDL_FRect rect);
|
||||
explicit Sprite(std::shared_ptr<Texture> texture);
|
||||
virtual ~Sprite() = default;
|
||||
public:
|
||||
// --- Constructores y destructor ---
|
||||
Sprite(std::shared_ptr<Texture> texture, float pos_x, float pos_y, float width, float height);
|
||||
Sprite(std::shared_ptr<Texture> texture, SDL_FRect rect);
|
||||
explicit Sprite(std::shared_ptr<Texture> texture);
|
||||
virtual ~Sprite() = default;
|
||||
|
||||
// --- Renderizado y control ---
|
||||
virtual void render(); // Muestra el sprite por pantalla
|
||||
virtual void clear(); // Reinicia las variables a cero
|
||||
// --- 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 ---
|
||||
[[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; }
|
||||
[[nodiscard]] auto getPosition() const -> SDL_FRect { return pos_; }
|
||||
auto getRect() -> SDL_FRect& { return pos_; }
|
||||
// --- Getters de posición y tamaño ---
|
||||
[[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; }
|
||||
[[nodiscard]] auto getPosition() const -> SDL_FRect { return pos_; }
|
||||
auto getRect() -> SDL_FRect& { return pos_; }
|
||||
|
||||
// --- Setters de posición y tamaño ---
|
||||
void setX(float pos_x) { pos_.x = pos_x; }
|
||||
void setY(float pos_y) { pos_.y = pos_y; }
|
||||
void setWidth(float width) { pos_.w = width; }
|
||||
void setHeight(float height) { pos_.h = height; }
|
||||
void setPosition(float pos_x, float pos_y);
|
||||
void setPosition(SDL_FPoint point);
|
||||
void setPosition(SDL_FRect rect) { pos_ = rect; }
|
||||
// --- Setters de posición y tamaño ---
|
||||
void setX(float pos_x) { pos_.x = pos_x; }
|
||||
void setY(float pos_y) { pos_.y = pos_y; }
|
||||
void setWidth(float width) { pos_.w = width; }
|
||||
void setHeight(float height) { pos_.h = height; }
|
||||
void setPosition(float pos_x, float pos_y);
|
||||
void setPosition(SDL_FPoint point);
|
||||
void setPosition(SDL_FRect rect) { pos_ = rect; }
|
||||
|
||||
// --- Zoom ---
|
||||
void setZoom(float zoom) { zoom_ = zoom; }
|
||||
// --- 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; }
|
||||
// --- Modificación de posición ---
|
||||
void incX(float value) { pos_.x += value; }
|
||||
void incY(float value) { pos_.y += value; }
|
||||
|
||||
// --- Sprite clip ---
|
||||
[[nodiscard]] auto getSpriteClip() const -> SDL_FRect { return sprite_clip_; }
|
||||
void setSpriteClip(SDL_FRect rect) { sprite_clip_ = rect; }
|
||||
void setSpriteClip(float pos_x, float pos_y, float width, float height) { sprite_clip_ = SDL_FRect{pos_x, pos_y, width, height}; }
|
||||
// --- Sprite clip ---
|
||||
[[nodiscard]] auto getSpriteClip() const -> SDL_FRect { return sprite_clip_; }
|
||||
void setSpriteClip(SDL_FRect rect) { sprite_clip_ = rect; }
|
||||
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; }
|
||||
// --- Textura ---
|
||||
[[nodiscard]] auto getTexture() const -> std::shared_ptr<Texture> { return texture_; }
|
||||
void setTexture(std::shared_ptr<Texture> texture) { texture_ = texture; }
|
||||
|
||||
protected:
|
||||
// --- 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
|
||||
protected:
|
||||
// --- 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
|
||||
};
|
||||
Reference in New Issue
Block a user