Sistema de múltiples texturas: - Carga ball.png (10x10) y ball_small.png (6x6) al inicio - Variable current_ball_size_ obtiene tamaño desde texture->getWidth() - Eliminar constante BALL_SIZE hardcoded Cambio de tamaño con ajuste de posiciones: - updateBallSizes() ajusta pos según gravedad y superficie - DOWN: mueve Y hacia abajo si crece - UP: mueve Y hacia arriba si crece - LEFT/RIGHT: mueve X correspondiente - Solo ajusta pelotas en superficie (isOnSurface()) Ball class actualizada: - Constructor recibe ball_size como parámetro - updateSize(new_size): actualiza hitbox y sprite - setTexture(texture): cambia textura del sprite - setPosition() usa setRotoBallScreenPosition() Sprite class: - Añadido setTexture() inline para hot-swap Tecla N: - Cicla entre texturas disponibles - Actualiza todas las pelotas sin reiniciar física - Texto informativo "SPRITE: NORMAL" / "SPRITE: SMALL" Fix bug initBalls(): - Ahora usa current_ball_size_ en constructor - Pelotas nuevas tienen tamaño correcto según textura activa 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL_rect.h> // for SDL_FRect, SDL_FPoint
|
|
|
|
#include <memory> // for shared_ptr
|
|
class Texture;
|
|
|
|
class Sprite {
|
|
private:
|
|
std::shared_ptr<Texture> texture_; // Textura con los gráficos del sprite
|
|
SDL_FRect pos_; // Posición y tamaño del sprite
|
|
SDL_FRect clip_; // Parte de la textura que se va a dibujar
|
|
|
|
public:
|
|
// Constructor
|
|
explicit Sprite(std::shared_ptr<Texture> texture);
|
|
|
|
// Destructor
|
|
~Sprite() = default;
|
|
|
|
// Establece la posición del sprite
|
|
void setPos(SDL_FPoint pos);
|
|
|
|
// Pinta el sprite
|
|
void render();
|
|
|
|
// Establece el rectangulo de la textura que se va a pintar
|
|
void setClip(SDL_FRect clip);
|
|
|
|
// Establece el tamaño del sprite
|
|
void setSize(float w, float h);
|
|
|
|
// Modulación de color
|
|
void setColor(int r, int g, int b);
|
|
|
|
// Cambio de textura dinámico
|
|
void setTexture(std::shared_ptr<Texture> texture) { texture_ = texture; }
|
|
}; |