Reestructurar código moviendo utilidades a source/external/
- Crear directorio source/external/ para componentes externos - Mover sprite.h/.cpp, texture.h/.cpp, dbgtxt.h, stb_image.h a external/ - Actualizar includes en main.cpp y ball.h para nueva estructura - Modificar CMakeLists.txt y Makefile para incluir external/*.cpp - Mantener lógica del juego (ball.h/.cpp, main.cpp) en source/ - Mejorar organización y separación de responsabilidades 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
40
source/external/sprite.cpp
vendored
Normal file
40
source/external/sprite.cpp
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user