merdetes pa debugar a gust
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
#include "game/options.hpp" // Para Cheat, Options, options
|
||||
#include "utils/defines.hpp" // Para RoomBorder::BOTTOM, RoomBorder::LEFT, RoomBorder::RIGHT
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include "core/system/debug.hpp" // Para Debug
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Player::Player(const Data& player)
|
||||
: room_(player.room) {
|
||||
@@ -29,7 +33,12 @@ Player::Player(const Data& player)
|
||||
// Pinta el jugador en pantalla
|
||||
void Player::render() {
|
||||
sprite_->render(1, color_);
|
||||
Screen::get()->getRendererSurface()->putPixel(under_right_foot_.x, under_right_foot_.y, 6);
|
||||
#ifdef _DEBUG
|
||||
if (Debug::get()->isEnabled()) {
|
||||
Screen::get()->getRendererSurface()->putPixel(under_right_foot_.x, under_right_foot_.y, static_cast<Uint8>(PaletteColor::GREEN));
|
||||
Screen::get()->getRendererSurface()->putPixel(under_left_foot_.x, under_left_foot_.y, static_cast<Uint8>(PaletteColor::GREEN));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
@@ -104,7 +113,7 @@ void Player::transitionToState(State state) {
|
||||
fall_sound_ctrl_.reset();
|
||||
current_slope_ = nullptr;
|
||||
break;
|
||||
case State::ON_SLOPE:
|
||||
case State::ON_SLOPE:
|
||||
std::cout << "ON_SLOPE\n";
|
||||
vy_ = 0;
|
||||
handleDeathByFalling();
|
||||
@@ -285,7 +294,7 @@ void Player::moveOnSlope(float delta_time) {
|
||||
}
|
||||
|
||||
// Ajustar la posición Y del jugador (restar HEIGHT porque foot_y es la posición del pie)
|
||||
y_ = foot_y - HEIGHT;
|
||||
y_ = foot_y - HEIGHT + 1;
|
||||
|
||||
// Verificar si el pie ha salido de los límites horizontales de la rampa
|
||||
// Usar min/max porque LEFT slopes tienen x1<x2 pero RIGHT slopes tienen x1>x2
|
||||
@@ -296,16 +305,16 @@ void Player::moveOnSlope(float delta_time) {
|
||||
if (OUT_OF_BOUNDS) {
|
||||
// Determinar si estamos saliendo por arriba o por abajo de la rampa
|
||||
const bool EXITING_DOWNWARD = (FOOT_X > current_slope_->x2 && IS_LEFT_SLOPE) ||
|
||||
(FOOT_X < current_slope_->x1 && !IS_LEFT_SLOPE);
|
||||
(FOOT_X < current_slope_->x1 && !IS_LEFT_SLOPE);
|
||||
|
||||
if (EXITING_DOWNWARD) {
|
||||
// Salida por abajo: bajar 1 pixel para ayudar detección de suelo
|
||||
y_ += 1.0F;
|
||||
// y_ += 1.0F;
|
||||
}
|
||||
// Si sale por arriba, mantener altura (ya está en foot_y - HEIGHT)
|
||||
|
||||
// El jugador ya no está en la rampa, limpiar referencia
|
||||
current_slope_ = nullptr;
|
||||
// current_slope_ = nullptr;
|
||||
|
||||
// Verificar si hay soporte debajo (suelo plano, conveyor belt, u otra slope)
|
||||
if (isOnFloor()) {
|
||||
@@ -591,13 +600,13 @@ auto Player::isOnSlope() -> bool {
|
||||
|
||||
// Verificar si cada pie está "volando" (sin soporte: ni top surface ni conveyor belt)
|
||||
const bool LEFT_FOOT_FLYING = !(room_->checkTopSurfaces(under_left_foot_) ||
|
||||
room_->checkConveyorBelts(under_left_foot_));
|
||||
room_->checkConveyorBelts(under_left_foot_));
|
||||
const bool RIGHT_FOOT_FLYING = !(room_->checkTopSurfaces(under_right_foot_) ||
|
||||
room_->checkConveyorBelts(under_right_foot_));
|
||||
room_->checkConveyorBelts(under_right_foot_));
|
||||
|
||||
// Retornar true si UN pie en rampa Y el OTRO volando
|
||||
return (LEFT_FOOT_ON_LEFT_SLOPE && RIGHT_FOOT_FLYING) ||
|
||||
(RIGHT_FOOT_ON_RIGHT_SLOPE && LEFT_FOOT_FLYING);
|
||||
(RIGHT_FOOT_ON_RIGHT_SLOPE && LEFT_FOOT_FLYING);
|
||||
}
|
||||
|
||||
// Comprueba si current_slope_ es una rampa izquierda (ascendente a la izquierda)
|
||||
@@ -614,7 +623,7 @@ auto Player::isLeftSlope() -> bool {
|
||||
// Actualiza current_slope_ con la rampa correcta según el pie que toca
|
||||
void Player::updateCurrentSlope() {
|
||||
updateFeet();
|
||||
|
||||
|
||||
// Left slopes (\) ascendentes a izquierda tocan el pie izquierdo
|
||||
if (room_->checkLeftSlopes(under_left_foot_)) {
|
||||
current_slope_ = room_->getSlopeAtPoint(under_left_foot_);
|
||||
@@ -809,6 +818,9 @@ void Player::syncSpriteAndCollider() {
|
||||
placeSprite(); // Coloca el sprite en la posición del jugador
|
||||
collider_box_ = getRect(); // Actualiza el rectangulo de colisión
|
||||
updateColliderPoints(); // Actualiza los puntos de colisión
|
||||
#ifdef _DEBUG
|
||||
updateFeet();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Coloca el sprite en la posición del jugador
|
||||
|
||||
Reference in New Issue
Block a user