Els sprites de la intro ja apareixen i desapareixen com en el CC original

This commit is contained in:
2025-03-08 17:47:13 +01:00
parent 83bdd67cee
commit e523692e99
4 changed files with 36 additions and 172 deletions

View File

@@ -73,46 +73,7 @@ void MovingSprite::update()
}
// Muestra el sprite por pantalla
void MovingSprite::render()
{
texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, rotate_.center, flip_);
}
// Establece el valor de la variable
void MovingSprite::setZoomW(float value)
{
zoom_w_ = value;
}
// Establece el valor de la variable
void MovingSprite::setZoomH(float value)
{
zoom_h_ = value;
}
// Establece el valor de la variable
void MovingSprite::setAngle(double value)
{
rotate_.angle = value;
}
// Establece el valor de la variable
void MovingSprite::setRotatingCenter(SDL_Point *point)
{
rotate_.center = point;
}
// Incrementa el valor del ángulo
void MovingSprite::updateAngle()
{
rotate_.angle += rotate_.amount;
}
// Obtiene el valor de la variable
bool MovingSprite::isRotating() const
{
return rotate_.enabled;
}
void MovingSprite::render() { texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, rotate_.center, flip_); }
// Establece la rotacion
void MovingSprite::rotate()
@@ -135,43 +96,6 @@ void MovingSprite::setRotate(bool enable)
rotate_.counter = 0;
}
// Establece el valor de la variable
void MovingSprite::setRotateSpeed(int value)
{
rotate_.speed = std::max(1, value);
}
// Establece el valor de la variable
void MovingSprite::setRotateAmount(double value)
{
rotate_.amount = value;
}
// Cambia el sentido de la rotación
void MovingSprite::switchRotate()
{
rotate_.amount *= -1;
}
// Establece el valor de la variable
void MovingSprite::setFlip(SDL_RendererFlip flip)
{
flip_ = flip;
}
// Gira el sprite horizontalmente
void MovingSprite::flip()
{
flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL;
}
// Obtiene el valor de la variable
SDL_RendererFlip MovingSprite::getFlip()
{
return flip_;
}
// Establece la posición y_ el tamaño del objeto
void MovingSprite::setPos(SDL_Rect rect)
{
@@ -204,27 +128,3 @@ void MovingSprite::setPosY(float value)
y_ = value;
pos_.y = static_cast<int>(y_);
}
// Establece el valor de la variable
void MovingSprite::setVelX(float value)
{
vx_ = value;
}
// Establece el valor de la variable
void MovingSprite::setVelY(float value)
{
vy_ = value;
}
// Establece el valor de la variable
void MovingSprite::setAccelX(float value)
{
ax_ = value;
}
// Establece el valor de la variable
void MovingSprite::setAccelY(float value)
{
ay_ = value;
}

View File

@@ -38,7 +38,7 @@ protected:
SDL_RendererFlip flip_; // Indica como se voltea el sprite
// Incrementa el valor del ángulo
void updateAngle();
void updateAngle() { rotate_.angle += rotate_.amount; }
// Mueve el sprite
void move();
@@ -73,40 +73,40 @@ public:
float getAccelY() const { return ay_; }
// Establece la variable
void setVelX(float value);
void setVelY(float value);
void setAccelX(float value);
void setAccelY(float value);
void setVelX(float value) { vx_ = value; }
void setVelY(float value) { vy_ = value; }
void setAccelX(float value) { ax_ = value; }
void setAccelY(float value) { ay_ = value; }
// Obten el valor de la variable
bool isRotating() const;
bool isRotating() const { return rotate_.enabled; }
// Establece el valor de la variable
void setZoomW(float value);
void setZoomH(float value);
void setZoomW(float value) { zoom_w_ = value; }
void setZoomH(float value) { zoom_h_ = value; }
// Establece el valor de la variable
void setAngle(double vaue);
void setRotatingCenter(SDL_Point *point);
void setAngle(double value) { rotate_.angle = value; }
void setRotatingCenter(SDL_Point *point) { rotate_.center = point; }
// Activa o desactiva el efecto de rotación
void setRotate(bool enable);
// Establece el valor de la variable
void setRotateSpeed(int value);
void setRotateAmount(double value);
void setRotateSpeed(int value) { rotate_.speed = std::max(1, value); }
void setRotateAmount(double value) { rotate_.amount = value; }
// Cambia el sentido de la rotación
void switchRotate();
void switchRotate() { rotate_.amount *= -1; }
// Establece el valor de la variable
void setFlip(SDL_RendererFlip flip);
void setFlip(SDL_RendererFlip flip) { flip_ = flip; }
// Gira el sprite horizontalmente
void flip();
void flip() { flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; }
// Obtiene el valor de la variable
SDL_RendererFlip getFlip();
SDL_RendererFlip getFlip() { return flip_; }
// Establece la posición y_ el tamaño del objeto
void setPos(SDL_Rect rect);

View File

@@ -17,22 +17,13 @@ void SmartSprite::update()
}
}
// Establece el valor de la variable
void SmartSprite::setFinishedCounter(int value)
// Dibuja el sprite
void SmartSprite::render()
{
finished_counter_ = value;
if (enabled_)
{
MovingSprite::render();
}
// Establece el valor de la variable
void SmartSprite::setDestX(int x)
{
dest_x_ = x;
}
// Establece el valor de la variable
void SmartSprite::setDestY(int y)
{
dest_y_ = y;
}
// Comprueba el movimiento
@@ -115,21 +106,3 @@ void SmartSprite::checkFinished()
}
}
}
// Obtiene el valor de la variable
bool SmartSprite::isOnDestination() const
{
return on_destination_;
}
// Obtiene el valor de la variable
bool SmartSprite::hasFinished() const
{
return finished_;
}
// Habilita el objeto
void SmartSprite::setEnabled(bool value)
{
enabled_ = value;
}

View File

@@ -32,27 +32,18 @@ public:
// Actualiza la posición y comprueba si ha llegado a su destino
void update() override;
// Establece el valor de la variable
void setFinishedCounter(int value);
// Dibuja el sprite
void render();
// Establece el valor de la variable
void setDestX(int x);
// Getters
int getDestX() const { return dest_x_; }
int getDestY() const { return dest_y_; }
bool isOnDestination() const { return on_destination_; }
bool hasFinished() const { return finished_; }
// Establece el valor de la variable
void setDestY(int y);
// Obtiene el valor de la variable
int getDestX() const;
// Obtiene el valor de la variable
int getDestY() const;
// Obtiene el valor de la variable
bool isOnDestination() const;
// Obtiene el valor de la variable
bool hasFinished() const;
// Habilita el objeto
void setEnabled(bool value);
// Setters
void setFinishedCounter(int value) { finished_counter_ = value; }
void setDestX(int x) { dest_x_ = x; }
void setDestY(int y) { dest_y_ = y; }
void setEnabled(bool value) { enabled_ = value; }
};