Els sprites de la intro ja apareixen i desapareixen com en el CC original
This commit is contained in:
@@ -73,46 +73,7 @@ void MovingSprite::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Muestra el sprite por pantalla
|
// Muestra el sprite por pantalla
|
||||||
void MovingSprite::render()
|
void MovingSprite::render() { texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, rotate_.center, flip_); }
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece la rotacion
|
// Establece la rotacion
|
||||||
void MovingSprite::rotate()
|
void MovingSprite::rotate()
|
||||||
@@ -135,43 +96,6 @@ void MovingSprite::setRotate(bool enable)
|
|||||||
rotate_.counter = 0;
|
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
|
// Establece la posición y_ el tamaño del objeto
|
||||||
void MovingSprite::setPos(SDL_Rect rect)
|
void MovingSprite::setPos(SDL_Rect rect)
|
||||||
{
|
{
|
||||||
@@ -204,27 +128,3 @@ void MovingSprite::setPosY(float value)
|
|||||||
y_ = value;
|
y_ = value;
|
||||||
pos_.y = static_cast<int>(y_);
|
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;
|
|
||||||
}
|
|
||||||
@@ -38,7 +38,7 @@ protected:
|
|||||||
SDL_RendererFlip flip_; // Indica como se voltea el sprite
|
SDL_RendererFlip flip_; // Indica como se voltea el sprite
|
||||||
|
|
||||||
// Incrementa el valor del ángulo
|
// Incrementa el valor del ángulo
|
||||||
void updateAngle();
|
void updateAngle() { rotate_.angle += rotate_.amount; }
|
||||||
|
|
||||||
// Mueve el sprite
|
// Mueve el sprite
|
||||||
void move();
|
void move();
|
||||||
@@ -73,40 +73,40 @@ public:
|
|||||||
float getAccelY() const { return ay_; }
|
float getAccelY() const { return ay_; }
|
||||||
|
|
||||||
// Establece la variable
|
// Establece la variable
|
||||||
void setVelX(float value);
|
void setVelX(float value) { vx_ = value; }
|
||||||
void setVelY(float value);
|
void setVelY(float value) { vy_ = value; }
|
||||||
void setAccelX(float value);
|
void setAccelX(float value) { ax_ = value; }
|
||||||
void setAccelY(float value);
|
void setAccelY(float value) { ay_ = value; }
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
bool isRotating() const;
|
bool isRotating() const { return rotate_.enabled; }
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setZoomW(float value);
|
void setZoomW(float value) { zoom_w_ = value; }
|
||||||
void setZoomH(float value);
|
void setZoomH(float value) { zoom_h_ = value; }
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setAngle(double vaue);
|
void setAngle(double value) { rotate_.angle = value; }
|
||||||
void setRotatingCenter(SDL_Point *point);
|
void setRotatingCenter(SDL_Point *point) { rotate_.center = point; }
|
||||||
|
|
||||||
// Activa o desactiva el efecto de rotación
|
// Activa o desactiva el efecto de rotación
|
||||||
void setRotate(bool enable);
|
void setRotate(bool enable);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setRotateSpeed(int value);
|
void setRotateSpeed(int value) { rotate_.speed = std::max(1, value); }
|
||||||
void setRotateAmount(double value);
|
void setRotateAmount(double value) { rotate_.amount = value; }
|
||||||
|
|
||||||
// Cambia el sentido de la rotación
|
// Cambia el sentido de la rotación
|
||||||
void switchRotate();
|
void switchRotate() { rotate_.amount *= -1; }
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setFlip(SDL_RendererFlip flip);
|
void setFlip(SDL_RendererFlip flip) { flip_ = flip; }
|
||||||
|
|
||||||
// Gira el sprite horizontalmente
|
// 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
|
// Obtiene el valor de la variable
|
||||||
SDL_RendererFlip getFlip();
|
SDL_RendererFlip getFlip() { return flip_; }
|
||||||
|
|
||||||
// Establece la posición y_ el tamaño del objeto
|
// Establece la posición y_ el tamaño del objeto
|
||||||
void setPos(SDL_Rect rect);
|
void setPos(SDL_Rect rect);
|
||||||
|
|||||||
@@ -17,22 +17,13 @@ void SmartSprite::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Dibuja el sprite
|
||||||
void SmartSprite::setFinishedCounter(int value)
|
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
|
// 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;
|
|
||||||
}
|
|
||||||
@@ -32,27 +32,18 @@ public:
|
|||||||
// Actualiza la posición y comprueba si ha llegado a su destino
|
// Actualiza la posición y comprueba si ha llegado a su destino
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Dibuja el sprite
|
||||||
void setFinishedCounter(int value);
|
void render();
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Getters
|
||||||
void setDestX(int x);
|
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
|
// Setters
|
||||||
void setDestY(int y);
|
void setFinishedCounter(int value) { finished_counter_ = value; }
|
||||||
|
void setDestX(int x) { dest_x_ = x; }
|
||||||
// Obtiene el valor de la variable
|
void setDestY(int y) { dest_y_ = y; }
|
||||||
int getDestX() const;
|
void setEnabled(bool value) { enabled_ = value; }
|
||||||
|
|
||||||
// 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);
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user