Corregido bug en el movimiento de los enemigos

This commit is contained in:
2022-11-12 10:31:29 +01:00
parent 6b4c089683
commit be872971f5
5 changed files with 76 additions and 69 deletions

View File

@@ -64,7 +64,20 @@ void Enemy::checkPath()
{
if (sprite->getPosX() > x2 || sprite->getPosX() < x1)
{
// Recoloca
if (sprite->getPosX() > x2)
{
sprite->setPosX(x2);
}
else
{
sprite->setPosX(x1);
}
// Cambia el sentido
sprite->setVelX(sprite->getVelX() * (-1));
// Invierte el sprite
if (doFlip)
{
sprite->flipH();
@@ -73,7 +86,20 @@ void Enemy::checkPath()
if (sprite->getPosY() > y2 || sprite->getPosY() < y1)
{
// Recoloca
if (sprite->getPosY() > y2)
{
sprite->setPosY(y2);
}
else
{
sprite->setPosY(y1);
}
// Cambia el sentido
sprite->setVelY(sprite->getVelY() * (-1));
// Invierte el sprite
if (doFlip)
{
sprite->flipH();