millorada una mica la classe Debug en quant a mostrar info
This commit is contained in:
@@ -84,21 +84,21 @@ void Player::move(float delta_time) {
|
||||
}
|
||||
syncSpriteAndCollider(); // Actualiza la posición del sprite y las colisiones
|
||||
#ifdef _DEBUG
|
||||
Debug::get()->add(std::string("X : " + std::to_string(static_cast<int>(x_))));
|
||||
Debug::get()->add(std::string("Y : " + std::to_string(static_cast<int>(y_))));
|
||||
Debug::get()->add(std::string("LGP: " + std::to_string(last_grounded_position_)));
|
||||
Debug::get()->set("P.X", std::to_string(static_cast<int>(x_)));
|
||||
Debug::get()->set("P.Y", std::to_string(static_cast<int>(y_)));
|
||||
Debug::get()->set("P.LGP", std::to_string(last_grounded_position_));
|
||||
switch (state_) {
|
||||
case State::ON_GROUND:
|
||||
Debug::get()->add(std::string("ON_GROUND"));
|
||||
Debug::get()->set("P.STATE", "ON_GROUND");
|
||||
break;
|
||||
case State::ON_SLOPE:
|
||||
Debug::get()->add(std::string("ON_SLOPE"));
|
||||
Debug::get()->set("P.STATE", "ON_SLOPE");
|
||||
break;
|
||||
case State::JUMPING:
|
||||
Debug::get()->add(std::string("JUMPING"));
|
||||
Debug::get()->set("P.STATE", "JUMPING");
|
||||
break;
|
||||
case State::FALLING:
|
||||
Debug::get()->add(std::string("FALLING"));
|
||||
Debug::get()->set("P.STATE", "FALLING");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -235,6 +235,9 @@ void Player::moveOnGround(float delta_time) {
|
||||
y_ = SLOPE_Y - HEIGHT;
|
||||
transitionToState(State::ON_SLOPE);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
Debug::get()->set("sl.detect_y", SLOPE_Y != Collision::NONE ? std::to_string(SLOPE_Y) : "-");
|
||||
#endif
|
||||
|
||||
// Comprueba si está sobre una rampa
|
||||
if (isOnSlope()) { transitionToState(State::ON_SLOPE); }
|
||||
@@ -279,12 +282,21 @@ void Player::moveOnSlope(float delta_time) {
|
||||
const int MAX_X = std::max(current_slope_->x1, current_slope_->x2);
|
||||
const bool OUT_OF_BOUNDS = (X < MIN_X) || (X > MAX_X);
|
||||
|
||||
#ifdef _DEBUG
|
||||
Debug::get()->set("sl.foot", std::to_string(X));
|
||||
Debug::get()->set("sl.y_c", std::to_string(static_cast<int>(y_)));
|
||||
Debug::get()->set("sl.oob", OUT_OF_BOUNDS ? "YES" : "ok");
|
||||
#endif
|
||||
|
||||
if (OUT_OF_BOUNDS) {
|
||||
// Determinar si estamos saliendo por arriba o por abajo de la rampa
|
||||
const bool EXITING_DOWNWARD = (X > current_slope_->x2 && IS_LEFT_SLOPE) ||
|
||||
(X < current_slope_->x1 && !IS_LEFT_SLOPE);
|
||||
const bool EXITING_UPWARD = (X < current_slope_->x1 && IS_LEFT_SLOPE) ||
|
||||
(X > current_slope_->x2 && !IS_LEFT_SLOPE);
|
||||
#ifdef _DEBUG
|
||||
Debug::get()->set("sl.oob", EXITING_DOWNWARD ? "DOWN" : "UP");
|
||||
#endif
|
||||
|
||||
if (EXITING_DOWNWARD) {
|
||||
// Salida por abajo: no hacer nada
|
||||
@@ -576,18 +588,17 @@ void Player::updateCurrentSlope() {
|
||||
}
|
||||
}
|
||||
|
||||
// Debug output
|
||||
/*
|
||||
#ifdef _DEBUG
|
||||
if (current_slope_ != nullptr) {
|
||||
const char* TYPE = isLeftSlope() ? "Left \\" : "Right /";
|
||||
std::cout << "[SLOPE] " << TYPE
|
||||
<< " from (" << current_slope_->x1 << "," << current_slope_->y1 << ")"
|
||||
<< " to (" << current_slope_->x2 << "," << current_slope_->y2 << ")\n";
|
||||
|
||||
Debug::get()->set("sl.type", isLeftSlope() ? "L\\" : "R/");
|
||||
Debug::get()->set("sl.p1", std::to_string(current_slope_->x1) + "," + std::to_string(current_slope_->y1));
|
||||
Debug::get()->set("sl.p2", std::to_string(current_slope_->x2) + "," + std::to_string(current_slope_->y2));
|
||||
} else {
|
||||
std::cout << "[SLOPE] nullptr\n";
|
||||
Debug::get()->set("sl.type", "null");
|
||||
Debug::get()->unset("sl.p1");
|
||||
Debug::get()->unset("sl.p2");
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
// Comprueba que el jugador no toque ningun tile de los que matan
|
||||
|
||||
Reference in New Issue
Block a user