passat el codi de pintar el mode debug de textura a surface

This commit is contained in:
2025-03-20 18:02:31 +01:00
parent f438e8946b
commit 0667e2105b
5 changed files with 91 additions and 109 deletions

View File

@@ -32,7 +32,7 @@ Player::Player(const PlayerData &player)
#ifdef DEBUG
debug_rect_x_ = {0, 0, 0, 0};
debug_rect_y_ = {0, 0, 0, 0};
debug_color_ = {0, 255, 0};
debug_color_ = static_cast<Uint8>(PaletteColor::GREEN);
debug_point_ = {0, 0};
#endif
}
@@ -256,7 +256,7 @@ void Player::move()
checkState(); // Comprueba el estado del jugador
#ifdef DEBUG
debug_color_ = {0, 255, 0};
debug_color_ = static_cast<Uint8>(PaletteColor::GREEN);
#endif
// Se mueve hacia la izquierda
@@ -292,10 +292,10 @@ void Player::move()
if (state_ != PlayerState::JUMPING)
{
const LineVertical LEFT_SIDE = {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(&LEFT_SIDE);
if (ly > -1)
const int LY = room_->checkLeftSlopes(&LEFT_SIDE);
if (LY > -1)
{
y_ = ly - HEIGHT_;
y_ = LY - HEIGHT_;
}
}
@@ -440,7 +440,7 @@ void Player::move()
y_ = POINT - HEIGHT_;
setState(PlayerState::STANDING);
#ifdef DEBUG
debug_color_ = {255, 255, 0};
debug_color_ = static_cast<Uint8>(PaletteColor::YELLOW);
debug_point_ = {(int)x_ + (WIDTH_ / 2), POINT};
#endif
}
@@ -450,7 +450,7 @@ void Player::move()
// Calcula la nueva posición
y_ += vy_;
#ifdef DEBUG
debug_color_ = {255, 0, 0};
debug_color_ = static_cast<Uint8>(PaletteColor::RED);
#endif
}
}
@@ -731,38 +731,30 @@ void Player::initSprite(const std::string &surface_path, const std::string &anim
// Pinta la información de debug del jugador
void Player::renderDebugInfo()
{
/*
if (Debug::get()->getEnabled())
{
auto renderer = Screen::get()->getRenderer();
auto surface = Screen::get()->getRendererSurface();
// Pinta los underfeet
SDL_SetRenderDrawColor(renderer, 255, 0, 255, 255);
SDL_RenderDrawPoint(renderer, under_feet_[0].x, under_feet_[0].y);
SDL_RenderDrawPoint(renderer, under_feet_[1].x, under_feet_[1].y);
surface->putPixel(under_feet_[0].x, under_feet_[0].y,static_cast<Uint8>(PaletteColor::BRIGHT_MAGENTA));
surface->putPixel(under_feet_[1].x, under_feet_[1].y,static_cast<Uint8>(PaletteColor::BRIGHT_MAGENTA));
// Pinta rectangulo del jugador
SDL_SetRenderDrawColor(renderer, debug_color_.r, debug_color_.g, debug_color_.b, 192);
SDL_Rect rect = getRect();
SDL_RenderFillRect(renderer, &rect);
SDL_SetRenderDrawColor(renderer, 0, 255, 255, 255);
SDL_RenderDrawRect(renderer, &rect);
surface->drawRectBorder(&rect, static_cast<Uint8>(PaletteColor::BRIGHT_CYAN));
// Pinta el rectangulo de movimiento
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
if (vx_ != 0.0f)
{
SDL_RenderFillRect(renderer, &debug_rect_x_);
surface->fillRect(&debug_rect_x_, static_cast<Uint8>(PaletteColor::BRIGHT_RED));
}
if (vy_ != 0.0f)
{
SDL_RenderFillRect(renderer, &debug_rect_y_);
surface->fillRect(&debug_rect_y_, static_cast<Uint8>(PaletteColor::BRIGHT_RED));
}
// Pinta el punto de debug
SDL_SetRenderDrawColor(renderer, rand() % 256, rand() % 256, rand() % 256, 255);
SDL_RenderDrawPoint(renderer, debug_point_.x, debug_point_.y);
surface->putPixel(debug_point_.x, debug_point_.y, rand() % 16);
}
*/
}
#endif
#endif // DEBUG