updated movingsprite.cpp

This commit is contained in:
2021-02-18 18:50:43 +01:00
parent 31696cb2d0
commit 5234d77e77
2 changed files with 29 additions and 21 deletions

View File

@@ -15,7 +15,8 @@ MovingSprite::~MovingSprite()
}
// Iniciador
void MovingSprite::init(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, LTexture *texture, SDL_Renderer *renderer)
void MovingSprite::init(float x, float y, Uint16 w, Uint16 h, float velx, float vely, float accelx, float accely,
LTexture *texture, SDL_Renderer *renderer)
{
// Establece el alto y el ancho del sprite
setWidth(w);
@@ -43,11 +44,17 @@ void MovingSprite::init(float x, float y, int w, int h, float velx, float vely,
setSpriteClip(0, 0, w, h);
}
// Mueve el sprite
// Coloca el sprite en su nueva posición en funcion de la velocidad
void MovingSprite::move()
{
mPosX += mVelX;
mPosY += mVelY;
}
// Actualiza las variables internas del sprite: posición y velocidad
void MovingSprite::update()
{
move();
mVelX += mAccelX;
mVelY += mAccelY;