forked from jaildesigner-jailgames/jaildoctors_dilemma
passat el codi de pintar el mode debug de textura a surface
This commit is contained in:
@@ -48,7 +48,7 @@ void Debug::render()
|
||||
y = 0;
|
||||
for (const auto &l : log_)
|
||||
{
|
||||
text->writeColored(x_ + 10, y, l, stringToColor("white"));
|
||||
text->writeColored(x_ + 10, y, l, static_cast<Uint8>(PaletteColor::WHITE));
|
||||
y += text->getCharacterSize() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ Game::Game(GameMode mode)
|
||||
#endif
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Debug::get()->setEnabled(false);
|
||||
Debug::get()->setEnabled(true);
|
||||
#endif
|
||||
|
||||
// Crea objetos e inicializa variables
|
||||
@@ -202,32 +202,34 @@ void Game::updateDebugInfo()
|
||||
// Pone la información de debug en pantalla
|
||||
void Game::renderDebugInfo()
|
||||
{
|
||||
/*
|
||||
|
||||
if (!Debug::get()->getEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
|
||||
// Borra el marcador
|
||||
SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 255);
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect);
|
||||
surface->fillRect(&rect, static_cast<Uint8>(PaletteColor::BLACK));
|
||||
|
||||
// Pinta la rejilla
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 255, 255, 32);
|
||||
for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
|
||||
{ // Lineas horizontales
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), 0, i, PLAY_AREA_RIGHT, i);
|
||||
/*for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
|
||||
{
|
||||
// Lineas horizontales
|
||||
surface->drawLine(0, i, PLAY_AREA_RIGHT, i, static_cast<Uint8>(PaletteColor::BRIGHT_BLACK));
|
||||
}
|
||||
for (int i = 0; i < PLAY_AREA_RIGHT; i += 8)
|
||||
{ // Lineas verticales
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), i, 0, i, PLAY_AREA_BOTTOM - 1);
|
||||
}
|
||||
{
|
||||
// Lineas verticales
|
||||
surface->drawLine(i, 0, i, PLAY_AREA_BOTTOM - 1, static_cast<Uint8>(PaletteColor::BRIGHT_BLACK));
|
||||
}*/
|
||||
|
||||
// Pinta el texto
|
||||
Debug::get()->setPos({1, 18 * 8});
|
||||
Debug::get()->render();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// Comprueba los eventos
|
||||
|
||||
@@ -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
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
#ifdef DEBUG
|
||||
SDL_Rect debug_rect_x_; // Rectangulo de desplazamiento para el modo debug
|
||||
SDL_Rect debug_rect_y_; // Rectangulo de desplazamiento para el modo debug
|
||||
Color debug_color_; // Color del recuadro de debug del jugador
|
||||
Uint8 debug_color_; // Color del recuadro de debug del jugador
|
||||
SDL_Point debug_point_; // Punto para debug
|
||||
#endif
|
||||
|
||||
|
||||
@@ -497,15 +497,15 @@ void Room::fillMapTexture()
|
||||
|
||||
#ifdef DEBUG
|
||||
if (Debug::get()->getEnabled())
|
||||
{ /*
|
||||
{
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
|
||||
// BottomSurfaces
|
||||
if (true)
|
||||
{
|
||||
for (auto l : bottom_floors_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 0, 0, 0xFF);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::BLUE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,9 +514,7 @@ void Room::fillMapTexture()
|
||||
{
|
||||
for (auto l : top_floors_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 0, 0xFF);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::RED));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,9 +523,7 @@ void Room::fillMapTexture()
|
||||
{
|
||||
for (auto l : left_walls_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 128, 128, 255, 0xFF);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x, l.y1, l.x, l.y2);
|
||||
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::GREEN));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,9 +532,7 @@ void Room::fillMapTexture()
|
||||
{
|
||||
for (auto l : right_walls_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 255, 0, 0xFF);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x, l.y1, l.x, l.y2);
|
||||
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::MAGENTA));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,9 +541,7 @@ void Room::fillMapTexture()
|
||||
{
|
||||
for (auto l : left_slopes_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 255, 0xFF);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y1, l.x2, l.y2);
|
||||
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::CYAN));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,9 +550,7 @@ void Room::fillMapTexture()
|
||||
{
|
||||
for (auto l : right_slopes_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 0, 255, 0xFF);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y1, l.x2, l.y2);
|
||||
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::YELLOW));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,14 +559,12 @@ void Room::fillMapTexture()
|
||||
{
|
||||
for (auto l : conveyor_belt_floors_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
|
||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::WHITE));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // DEBUG
|
||||
Screen::get()->setRendererSurface(previuos_renderer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user