Ya muere al caer de alto

This commit is contained in:
2022-09-15 17:01:56 +02:00
parent d53f2695a0
commit 8ad496b510
5 changed files with 33 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Ren
onBorder = false;
border = BORDER_TOP;
invincible = false;
alive = true;
maxFallHeight = BLOCK * 4;
jumpIni = ini.jumpIni;
state = ini.state;
@@ -229,6 +231,10 @@ void Player::checkState()
else if (state == s_standing)
{
if (prevState == s_falling && fallCounter > maxFallHeight)
{ // Si cae de muy alto, el jugador muere
alive = false;
}
vy = 0.0f;
jumpCounter = 0;
fallCounter = 0;
@@ -652,4 +658,10 @@ void Player::setState(state_e value)
{
prevState = state;
state = value;
}
// Comprueba si el jugador esta vivo
bool Player::isAlive()
{
return alive;
}