Implementado el salto del jugador

This commit is contained in:
2022-08-17 13:44:41 +02:00
parent 9bd1e9b936
commit 02c2c1bce2

View File

@@ -26,7 +26,7 @@ Player::Player(SDL_Renderer *renderer, Asset *asset, Input *input, Map *map)
sprite->setCurrentAnimation("stand");
sprite->setFlip(SDL_FLIP_HORIZONTAL);
gravity = 0.5f;
gravity = 0.3f;
can_jump = true;
standing = true;
invulnerable = true;
@@ -89,12 +89,17 @@ void Player::checkInput()
vx = 0;
sprite->setCurrentAnimation("stand");
}
if (input->checkInput(INPUT_UP, REPEAT_FALSE))
{
vy = -5.0f;
}
}
// Aplica la gravedad
void Player::addGravity()
{
vy = gravity;
vy = std::min(vy += gravity, 2.0f);
}
// Actualiza los puntos de colisión