forked from jaildesigner-jailgames/jaildoctors_dilemma
Ya muere al caer de alto
This commit is contained in:
@@ -188,6 +188,7 @@ void Game::update()
|
|||||||
checkPlayerOnBorder();
|
checkPlayerOnBorder();
|
||||||
checkPlayerAndItems();
|
checkPlayerAndItems();
|
||||||
checkPlayerAndEnemies();
|
checkPlayerAndEnemies();
|
||||||
|
checkIfPlayerIsAlive();
|
||||||
scoreboard->update();
|
scoreboard->update();
|
||||||
updateDebugInfo();
|
updateDebugInfo();
|
||||||
}
|
}
|
||||||
@@ -330,6 +331,15 @@ void Game::checkPlayerAndItems()
|
|||||||
room->itemCollision(player->getCollider());
|
room->itemCollision(player->getCollider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba si el jugador esta vivo
|
||||||
|
void Game::checkIfPlayerIsAlive()
|
||||||
|
{
|
||||||
|
if (!player->isAlive())
|
||||||
|
{
|
||||||
|
killPlayer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Mata al jugador
|
// Mata al jugador
|
||||||
void Game::killPlayer()
|
void Game::killPlayer()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ private:
|
|||||||
// Comprueba las colisiones del jugador con los objetos
|
// Comprueba las colisiones del jugador con los objetos
|
||||||
void checkPlayerAndItems();
|
void checkPlayerAndItems();
|
||||||
|
|
||||||
|
// Comprueba si el jugador esta vivo
|
||||||
|
void checkIfPlayerIsAlive();
|
||||||
|
|
||||||
// Mata al jugador
|
// Mata al jugador
|
||||||
void killPlayer();
|
void killPlayer();
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Ren
|
|||||||
onBorder = false;
|
onBorder = false;
|
||||||
border = BORDER_TOP;
|
border = BORDER_TOP;
|
||||||
invincible = false;
|
invincible = false;
|
||||||
|
alive = true;
|
||||||
|
maxFallHeight = BLOCK * 4;
|
||||||
|
|
||||||
jumpIni = ini.jumpIni;
|
jumpIni = ini.jumpIni;
|
||||||
state = ini.state;
|
state = ini.state;
|
||||||
@@ -229,6 +231,10 @@ void Player::checkState()
|
|||||||
|
|
||||||
else if (state == s_standing)
|
else if (state == s_standing)
|
||||||
{
|
{
|
||||||
|
if (prevState == s_falling && fallCounter > maxFallHeight)
|
||||||
|
{ // Si cae de muy alto, el jugador muere
|
||||||
|
alive = false;
|
||||||
|
}
|
||||||
vy = 0.0f;
|
vy = 0.0f;
|
||||||
jumpCounter = 0;
|
jumpCounter = 0;
|
||||||
fallCounter = 0;
|
fallCounter = 0;
|
||||||
@@ -652,4 +658,10 @@ void Player::setState(state_e value)
|
|||||||
{
|
{
|
||||||
prevState = state;
|
prevState = state;
|
||||||
state = value;
|
state = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba si el jugador esta vivo
|
||||||
|
bool Player::isAlive()
|
||||||
|
{
|
||||||
|
return alive;
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,8 @@ public:
|
|||||||
std::vector<JA_Sound> fallSound; // Vecor con todos los sonidos de la caída
|
std::vector<JA_Sound> fallSound; // Vecor con todos los sonidos de la caída
|
||||||
int jumpCounter; // Cuenta el tiempo de salto
|
int jumpCounter; // Cuenta el tiempo de salto
|
||||||
int fallCounter; // Cuenta el tiempo de caida
|
int fallCounter; // Cuenta el tiempo de caida
|
||||||
|
bool alive; // Indica si el jugador esta vivo o no
|
||||||
|
int maxFallHeight; // Altura maxima permitida de caída.
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
// Comprueba las entradas y modifica variables
|
// Comprueba las entradas y modifica variables
|
||||||
@@ -158,6 +160,9 @@ public:
|
|||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setInvincible(bool value);
|
void setInvincible(bool value);
|
||||||
|
|
||||||
|
// Comprueba si el jugador esta vivo
|
||||||
|
bool isAlive();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
3
todo.txt
3
todo.txt
@@ -11,6 +11,9 @@ x (A) Modificar el salto para que coincida con el del JSW, no ha de colisionar l
|
|||||||
|
|
||||||
(A) Crear tiles que arrastren, tipo cinta transportadora
|
(A) Crear tiles que arrastren, tipo cinta transportadora
|
||||||
(A) Tiles animados
|
(A) Tiles animados
|
||||||
|
(A) Tile que maten (o enemigos?)
|
||||||
|
(A) Cuando mueres, pantalla negra entre vida y vida
|
||||||
|
x (A) Morir al caer de alto
|
||||||
x (A) Crear ascensores (NO SE VA A HACER POR DISEÑO)
|
x (A) Crear ascensores (NO SE VA A HACER POR DISEÑO)
|
||||||
x (A) Crear rampas
|
x (A) Crear rampas
|
||||||
x (A) Enemigos de diferente tamaño {cm:2022-08-30}
|
x (A) Enemigos de diferente tamaño {cm:2022-08-30}
|
||||||
|
|||||||
Reference in New Issue
Block a user