migracio de Title a time based

This commit is contained in:
2025-10-26 23:07:08 +01:00
parent fc17131455
commit 87370dd11d
12 changed files with 150 additions and 134 deletions

View File

@@ -30,7 +30,7 @@ Player::Player(const PlayerData& player)
under_feet_.resize(under_feet_.size() + 2, {0, 0});
feet_.resize(feet_.size() + 2, {0, 0});
#ifdef DEBUG
#ifdef _DEBUG
debug_rect_x_ = {0, 0, 0, 0};
debug_rect_y_ = {0, 0, 0, 0};
debug_color_ = static_cast<Uint8>(PaletteColor::GREEN);
@@ -42,7 +42,7 @@ Player::Player(const PlayerData& player)
void Player::render() {
sprite_->render(1, color_);
#ifdef DEBUG
#ifdef _DEBUG
renderDebugInfo();
#endif
}
@@ -221,7 +221,7 @@ void Player::move() {
applyGravity(); // Aplica gravedad al jugador
checkState(); // Comprueba el estado del jugador
#ifdef DEBUG
#ifdef _DEBUG
debug_color_ = static_cast<Uint8>(PaletteColor::GREEN);
#endif
@@ -234,7 +234,7 @@ void Player::move() {
proj.h = HEIGHT_;
proj.w = static_cast<int>(std::ceil(std::fabs(vx_))); // Para evitar que tenga un ancho de 0 pixels
#ifdef DEBUG
#ifdef _DEBUG
debug_rect_x_ = proj;
#endif
@@ -274,7 +274,7 @@ void Player::move() {
proj.h = HEIGHT_;
proj.w = ceil(vx_); // Para evitar que tenga un ancho de 0 pixels
#ifdef DEBUG
#ifdef _DEBUG
debug_rect_x_ = proj;
#endif
@@ -328,7 +328,7 @@ void Player::move() {
proj.h = static_cast<int>(std::ceil(std::fabs(vy_))); // Para evitar que tenga una altura de 0 pixels
proj.w = WIDTH_;
#ifdef DEBUG
#ifdef _DEBUG
debug_rect_y_ = proj;
#endif
@@ -355,7 +355,7 @@ void Player::move() {
proj.h = ceil(vy_); // Para evitar que tenga una altura de 0 pixels
proj.w = WIDTH_;
#ifdef DEBUG
#ifdef _DEBUG
debug_rect_y_ = proj;
#endif
@@ -380,7 +380,7 @@ void Player::move() {
// Calcula la nueva posición
y_ = POINT - HEIGHT_;
setState(PlayerState::STANDING);
#ifdef DEBUG
#ifdef _DEBUG
debug_color_ = static_cast<Uint8>(PaletteColor::YELLOW);
debug_point_ = {x_ + (WIDTH_ / 2), POINT};
#endif
@@ -388,7 +388,7 @@ void Player::move() {
// No está saltando y no hay colisón con una rampa
// Calcula la nueva posición
y_ += vy_;
#ifdef DEBUG
#ifdef _DEBUG
debug_color_ = static_cast<Uint8>(PaletteColor::RED);
#endif
}
@@ -403,7 +403,7 @@ void Player::move() {
placeSprite(); // Coloca el sprite en la nueva posición
collider_box_ = getRect(); // Actualiza el rectangulo de colisión
#ifdef DEBUG
#ifdef _DEBUG
Debug::get()->add("RECT_X: " + std::to_string(debug_rect_x_.x) + "," + std::to_string(debug_rect_x_.y) + "," + std::to_string(debug_rect_x_.w) + "," + std::to_string(debug_rect_x_.h));
Debug::get()->add("RECT_Y: " + std::to_string(debug_rect_y_.x) + "," + std::to_string(debug_rect_y_.y) + "," + std::to_string(debug_rect_y_.w) + "," + std::to_string(debug_rect_y_.h));
#endif
@@ -436,7 +436,7 @@ void Player::playJumpSound() {
JA_PlaySound(jumping_sound_[jumping_counter_ / 4]);
}
#ifdef DEBUG
#ifdef _DEBUG
Debug::get()->add("JUMP: " + std::to_string(jumping_counter_ / 4));
#endif
}
@@ -447,7 +447,7 @@ void Player::playFallSound() {
JA_PlaySound(falling_sound_[std::min((falling_counter_ / 4), (int)falling_sound_.size() - 1)]);
}
#ifdef DEBUG
#ifdef _DEBUG
Debug::get()->add("FALL: " + std::to_string(falling_counter_ / 4));
#endif
}
@@ -470,7 +470,7 @@ bool Player::isOnFloor() {
on_slope_l = room_->checkLeftSlopes(&under_feet_[0]);
on_slope_r = room_->checkRightSlopes(&under_feet_[1]);
#ifdef DEBUG
#ifdef _DEBUG
if (on_floor) {
Debug::get()->add("ON_FLOOR");
}
@@ -498,7 +498,7 @@ bool Player::isOnAutoSurface() {
on_auto_surface |= room_->checkAutoSurfaces(&f);
}
#ifdef DEBUG
#ifdef _DEBUG
if (on_auto_surface) {
Debug::get()->add("ON_AUTO_SURFACE");
}
@@ -522,7 +522,7 @@ bool Player::isOnDownSlope() {
on_slope |= room_->checkLeftSlopes(&under_feet_[0]);
on_slope |= room_->checkRightSlopes(&under_feet_[1]);
#ifdef DEBUG
#ifdef _DEBUG
if (on_slope) {
Debug::get()->add("ON_DOWN_SLOPE");
}
@@ -627,7 +627,7 @@ void Player::initSprite(const std::string& surface_path, const std::string& anim
sprite_->setCurrentAnimation("walk");
}
#ifdef DEBUG
#ifdef _DEBUG
// Pinta la información de debug del jugador
void Player::renderDebugInfo() {
if (Debug::get()->getEnabled()) {
@@ -653,4 +653,4 @@ void Player::renderDebugInfo() {
surface->putPixel(debug_point_.x, debug_point_.y, rand() % 16);
}
}
#endif // DEBUG
#endif // _DEBUG