commit de acabar la jornada laboral

This commit is contained in:
2024-10-17 13:57:41 +02:00
parent db884cb422
commit 59de566c5b
24 changed files with 78 additions and 274 deletions

View File

@@ -4,6 +4,8 @@
// Constructor
MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos, Rotate rotate, float zoom_w, float zoom_h, SDL_RendererFlip flip)
: Sprite(texture, pos),
x_(pos.x),
y_(pos.y),
rotate_(rotate),
zoom_w_(zoom_w),
zoom_h_(zoom_h),
@@ -11,6 +13,8 @@ MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos, Rotat
MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos)
: Sprite(texture, pos),
x_(pos.x),
y_(pos.y),
rotate_({false, 0, 0, 0.0f, 0.0f, nullptr}),
zoom_w_(1.0f),
zoom_h_(1.0f),
@@ -59,6 +63,8 @@ void MovingSprite::move()
vx_ += ax_;
vy_ += ay_;
syncPos();
}
// Actualiza las variables internas del objeto
@@ -243,8 +249,7 @@ void MovingSprite::setPos(float x, float y)
x_ = x;
y_ = y;
pos_.x = (int)x;
pos_.y = (int)y;
syncPos();
}
// Establece el valor de la variable
@@ -284,3 +289,10 @@ void MovingSprite::setAccelY(float value)
{
ay_ = value;
}
// Sincroniza la posición
void MovingSprite::syncPos()
{
pos_.x = (int)x_;
pos_.y = (int)y_;
}