Arreglos en la estructura i format del codi
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
// IWYU pragma: no_include <bits/std_abs.h>
|
||||
#include "player.h"
|
||||
#include <stdlib.h> // Para rand
|
||||
#include <algorithm> // Para max, min
|
||||
#include <cmath> // Para ceil, abs
|
||||
#include "animated_sprite.h" // Para AnimatedSprite
|
||||
#include "asset.h" // Para Asset
|
||||
#include "defines.h" // Para BORDER_TOP, BLOCK, BORDER_BOTTOM, BORDER...
|
||||
#include "debug.h" // Para Debug
|
||||
#include "input.h" // Para Input, inputs_e
|
||||
#include "jail_audio.h" // Para JA_LoadSound, JA_Sound_t, JA_PlaySound
|
||||
#include "resource.h" // Para Resource
|
||||
#include "room.h" // Para Room, tile_e
|
||||
#include "texture.h" // Para Texture
|
||||
#include "options.h"
|
||||
#include "screen.h"
|
||||
#include <stdlib.h> // for rand
|
||||
#include <algorithm> // for max, min
|
||||
#include <cmath> // for ceil, abs
|
||||
#include "animated_sprite.h" // for AnimatedSprite
|
||||
#include "debug.h" // for Debug
|
||||
#include "defines.h" // for BORDER_BOTTOM, BORDER_LEFT, BORDER_RIGHT
|
||||
#include "input.h" // for Input, InputAction
|
||||
#include "jail_audio.h" // for JA_PlaySound
|
||||
#include "options.h" // for Options, options, Cheat, OptionsVideo
|
||||
#include "resource.h" // for Resource
|
||||
#include "room.h" // for Room, JA_Sound_t, TileType
|
||||
#include "screen.h" // for Screen
|
||||
#include "texture.h" // for Texture
|
||||
|
||||
// Constructor
|
||||
Player::Player(const PlayerData &player)
|
||||
@@ -289,7 +288,7 @@ void Player::move()
|
||||
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende
|
||||
if (state_ != PlayerState::JUMPING)
|
||||
{
|
||||
v_line_t leftSide = {static_cast<int>(x_), static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo
|
||||
LineVertical leftSide = {static_cast<int>(x_), static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo
|
||||
const int ly = room_->checkLeftSlopes(&leftSide);
|
||||
if (ly > -1)
|
||||
{
|
||||
@@ -336,7 +335,7 @@ void Player::move()
|
||||
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende
|
||||
if (state_ != PlayerState::JUMPING)
|
||||
{
|
||||
v_line_t rightSide = {static_cast<int>(x_) + WIDTH_ - 1, static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo
|
||||
LineVertical rightSide = {static_cast<int>(x_) + WIDTH_ - 1, static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo
|
||||
const int ry = room_->checkRightSlopes(&rightSide);
|
||||
if (ry > -1)
|
||||
{
|
||||
@@ -428,8 +427,8 @@ void Player::move()
|
||||
// Si no hay colisión con los muros, comprueba la colisión con las rampas
|
||||
if (state_ != PlayerState::JUMPING)
|
||||
{ // Las rampas no se miran si se está saltando
|
||||
v_line_t leftSide = {proj.x, proj.y, proj.y + proj.h - 1};
|
||||
v_line_t rightSide = {proj.x + proj.w - 1, proj.y, proj.y + proj.h - 1};
|
||||
LineVertical leftSide = {proj.x, proj.y, proj.y + proj.h - 1};
|
||||
LineVertical rightSide = {proj.x + proj.w - 1, proj.y, proj.y + proj.h - 1};
|
||||
const int p = std::max(room_->checkRightSlopes(&rightSide), room_->checkLeftSlopes(&leftSide));
|
||||
if (p > -1)
|
||||
{
|
||||
@@ -618,21 +617,17 @@ bool Player::checkKillingTiles()
|
||||
// Actualiza los puntos de colisión
|
||||
updateColliderPoints();
|
||||
|
||||
// Comprueba si hay contacto
|
||||
bool check = false;
|
||||
|
||||
for (auto c : collider_points_)
|
||||
// Comprueba si hay contacto y retorna en cuanto se encuentra colisión
|
||||
for (const auto &c : collider_points_)
|
||||
{
|
||||
check |= (room_->getTile(c) == t_kill);
|
||||
if (room_->getTile(c) == TileType::KILL)
|
||||
{
|
||||
is_alive_ = false; // Mata al jugador inmediatamente
|
||||
return true; // Retorna en cuanto se detecta una colisión
|
||||
}
|
||||
}
|
||||
|
||||
// Mata al jugador si hay colisión
|
||||
if (check)
|
||||
{
|
||||
is_alive_ = false;
|
||||
}
|
||||
|
||||
return check;
|
||||
return false; // No se encontró ninguna colisión
|
||||
}
|
||||
|
||||
// Establece el color del jugador
|
||||
@@ -705,13 +700,6 @@ void Player::initSounds()
|
||||
}
|
||||
}
|
||||
|
||||
// Coloca el sprite en la posición del jugador
|
||||
void Player::placeSprite()
|
||||
{
|
||||
sprite_->setPosX(x_);
|
||||
sprite_->setPosY(y_);
|
||||
}
|
||||
|
||||
// Aplica los valores de spawn al jugador
|
||||
void Player::applySpawnValues(const PlayerSpawn &spawn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user