corregido un bug en la caída del personaje

This commit is contained in:
2022-08-28 07:30:13 +02:00
parent bc464206c1
commit b6cbc65a2a

View File

@@ -219,7 +219,6 @@ void Player::move()
vx = 0.0f;
}
// Mueve en el eje Y y comprueba colisiones con muros
y += vy;
if (checkMapCollisions())
@@ -238,8 +237,8 @@ void Player::move()
vy = 0.0f;
}
// Si no hay colisiones con los muros en el eje Y, comprueba no haya atravesado
// el suelo de un tile atravesble
// Si no hay colisiones con los muros en el eje Y, comprueba
// no haya atravesado el suelo de un tile atravesble
else
{
const int a = (lastPosition.y + h) / tileSize;
@@ -265,14 +264,20 @@ void Player::move()
}
}
const bool going_down2 = vy >= 0.0f;
const bool tile_aligned2 = ((int)y + h) % tileSize == 0;
// Si está cayendo
if (vy >= 0.0f)
if (going_down2)
{
state = falling;
if (isOnFloor())
// Si está alineado con el tile mira el suelo (para que no lo mire si está
// dentro de un tile atravesable y lo deje a medias)
if (tile_aligned2)
{
state = standing;
if (isOnFloor())
{
state = standing;
}
}
// Si no esta enganchado a una plataforma