- Reformatear archivos .cpp y .h según configuración Google personalizada - Mejorar consistencia en indentación y espaciado - Reorganizar includes y declaraciones de clases - Mantener funcionalidad existente sin cambios 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
36 lines
759 B
C++
36 lines
759 B
C++
#include "sprite.h"
|
|
|
|
#include "texture.h" // for Texture
|
|
|
|
// Constructor
|
|
Sprite::Sprite(std::shared_ptr<Texture> texture)
|
|
: texture_(texture),
|
|
pos_{0.0f, 0.0f, 0.0f, 0.0f},
|
|
clip_{0.0f, 0.0f, 0.0f, 0.0f} {}
|
|
|
|
// Establece la posición del sprite
|
|
void Sprite::setPos(SDL_FPoint pos) {
|
|
pos_.x = pos.x;
|
|
pos_.y = pos.y;
|
|
}
|
|
|
|
// Pinta el sprite
|
|
void Sprite::render() {
|
|
texture_->render(&clip_, &pos_);
|
|
}
|
|
|
|
// Establece el rectangulo de la textura que se va a pintar
|
|
void Sprite::setClip(SDL_FRect clip) {
|
|
clip_ = clip;
|
|
}
|
|
|
|
// Establece el tamaño del sprite
|
|
void Sprite::setSize(float w, float h) {
|
|
pos_.w = w;
|
|
pos_.h = h;
|
|
}
|
|
|
|
// Modulación de color
|
|
void Sprite::setColor(int r, int g, int b) {
|
|
texture_->setColor(r, g, b);
|
|
} |