Tiles que matan hecho

This commit is contained in:
2022-09-15 17:31:53 +02:00
parent 2967ccdae7
commit bc2cc28e76
3 changed files with 21 additions and 17 deletions

View File

@@ -134,11 +134,12 @@ void Player::render()
// Actualiza las variables del objeto
void Player::update()
{
checkInput(); // Comprueba las entradas y modifica variables
move(); // Recalcula la posición del jugador
animate(); // Establece la animación del jugador
checkBorders(); // Comprueba si está situado en alguno de los cuatro bordes de la habitación
checkJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio
checkInput(); // Comprueba las entradas y modifica variables
move(); // Recalcula la posición del jugador
animate(); // Establece la animación del jugador
checkBorders(); // Comprueba si está situado en alguno de los cuatro bordes de la habitación
checkJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio
checkKillingTiles(); // Comprueba que el jugador no toque ningun tile de los que matan
}
// Comprueba las entradas y modifica variables
@@ -568,21 +569,24 @@ bool Player::isOnDownSlope()
return onSlope;
}
// Comprueba que el jugador no atraviese ninguna pared
bool Player::checkWalls()
// Comprueba que el jugador no toque ningun tile de los que matan
bool Player::checkKillingTiles()
{
// Actualiza los puntos de colisión
updateColliderPoints();
// Comprueba si ha colisionado con un muro
bool wall = false;
// Comprueba si hay contacto
bool check = false;
for (auto c : colliderPoints)
{
wall |= (room->getTile(c) == t_wall);
check |= (room->getTile(c) == t_kill);
}
return wall;
// Mata al jugador si hay colisión
alive = !check;
return check;
}
// Obtiene algunos parametros del jugador

View File

@@ -106,8 +106,8 @@ public:
// Comprueba si el jugador está sobre una rampa hacia abajo
bool isOnDownSlope();
// Comprueba que el jugador no atraviese ninguna pared
bool checkWalls();
// Comprueba que el jugador no toque ningun tile de los que matan
bool checkKillingTiles();
// Actualiza los puntos de colisión
void updateColliderPoints();

View File

@@ -633,14 +633,14 @@ tile_e Room::getTile(int index)
return t_slope_l;
}
// Las filas 10-17 son de tiles t_passable
if ((tilemap[index] >= 10 * tilesetWidth) && (tilemap[index] < 18 * tilesetWidth))
// Las filas 10-18 son de tiles t_passable
if ((tilemap[index] >= 10 * tilesetWidth) && (tilemap[index] < 19 * tilesetWidth))
{
return t_passable;
}
// Las fila 18 es de tiles t_kill
if ((tilemap[index] >= 18 * tilesetWidth) && (tilemap[index] < 19 * tilesetWidth))
// Las fila 19 es de tiles t_kill
if ((tilemap[index] >= 19 * tilesetWidth) && (tilemap[index] < 20 * tilesetWidth))
{
return t_kill;
}