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;
|
y = 0;
|
||||||
for (const auto &l : log_)
|
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;
|
y += text->getCharacterSize() + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Game::Game(GameMode mode)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Debug::get()->setEnabled(false);
|
Debug::get()->setEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea objetos e inicializa variables
|
// Crea objetos e inicializa variables
|
||||||
@@ -202,32 +202,34 @@ void Game::updateDebugInfo()
|
|||||||
// Pone la información de debug en pantalla
|
// Pone la información de debug en pantalla
|
||||||
void Game::renderDebugInfo()
|
void Game::renderDebugInfo()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (!Debug::get()->getEnabled())
|
if (!Debug::get()->getEnabled())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto surface = Screen::get()->getRendererSurface();
|
||||||
|
|
||||||
// Borra el marcador
|
// Borra el marcador
|
||||||
SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
|
SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 255);
|
surface->fillRect(&rect, static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect);
|
|
||||||
|
|
||||||
// Pinta la rejilla
|
// Pinta la rejilla
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 255, 255, 32);
|
/*for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
|
||||||
for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
|
{
|
||||||
{ // Lineas horizontales
|
// Lineas horizontales
|
||||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), 0, i, PLAY_AREA_RIGHT, i);
|
surface->drawLine(0, i, PLAY_AREA_RIGHT, i, static_cast<Uint8>(PaletteColor::BRIGHT_BLACK));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < PLAY_AREA_RIGHT; i += 8)
|
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
|
// Pinta el texto
|
||||||
Debug::get()->setPos({1, 18 * 8});
|
Debug::get()->setPos({1, 18 * 8});
|
||||||
Debug::get()->render();
|
Debug::get()->render();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los eventos
|
// Comprueba los eventos
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ Player::Player(const PlayerData &player)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug_rect_x_ = {0, 0, 0, 0};
|
debug_rect_x_ = {0, 0, 0, 0};
|
||||||
debug_rect_y_ = {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};
|
debug_point_ = {0, 0};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ void Player::move()
|
|||||||
checkState(); // Comprueba el estado del jugador
|
checkState(); // Comprueba el estado del jugador
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug_color_ = {0, 255, 0};
|
debug_color_ = static_cast<Uint8>(PaletteColor::GREEN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Se mueve hacia la izquierda
|
// Se mueve hacia la izquierda
|
||||||
@@ -292,10 +292,10 @@ void Player::move()
|
|||||||
if (state_ != PlayerState::JUMPING)
|
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 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);
|
const int LY = room_->checkLeftSlopes(&LEFT_SIDE);
|
||||||
if (ly > -1)
|
if (LY > -1)
|
||||||
{
|
{
|
||||||
y_ = ly - HEIGHT_;
|
y_ = LY - HEIGHT_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,7 +440,7 @@ void Player::move()
|
|||||||
y_ = POINT - HEIGHT_;
|
y_ = POINT - HEIGHT_;
|
||||||
setState(PlayerState::STANDING);
|
setState(PlayerState::STANDING);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug_color_ = {255, 255, 0};
|
debug_color_ = static_cast<Uint8>(PaletteColor::YELLOW);
|
||||||
debug_point_ = {(int)x_ + (WIDTH_ / 2), POINT};
|
debug_point_ = {(int)x_ + (WIDTH_ / 2), POINT};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -450,7 +450,7 @@ void Player::move()
|
|||||||
// Calcula la nueva posición
|
// Calcula la nueva posición
|
||||||
y_ += vy_;
|
y_ += vy_;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug_color_ = {255, 0, 0};
|
debug_color_ = static_cast<Uint8>(PaletteColor::RED);
|
||||||
#endif
|
#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
|
// Pinta la información de debug del jugador
|
||||||
void Player::renderDebugInfo()
|
void Player::renderDebugInfo()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (Debug::get()->getEnabled())
|
if (Debug::get()->getEnabled())
|
||||||
{
|
{
|
||||||
auto renderer = Screen::get()->getRenderer();
|
auto surface = Screen::get()->getRendererSurface();
|
||||||
|
|
||||||
// Pinta los underfeet
|
// Pinta los underfeet
|
||||||
SDL_SetRenderDrawColor(renderer, 255, 0, 255, 255);
|
surface->putPixel(under_feet_[0].x, under_feet_[0].y,static_cast<Uint8>(PaletteColor::BRIGHT_MAGENTA));
|
||||||
SDL_RenderDrawPoint(renderer, under_feet_[0].x, under_feet_[0].y);
|
surface->putPixel(under_feet_[1].x, under_feet_[1].y,static_cast<Uint8>(PaletteColor::BRIGHT_MAGENTA));
|
||||||
SDL_RenderDrawPoint(renderer, under_feet_[1].x, under_feet_[1].y);
|
|
||||||
|
|
||||||
// Pinta rectangulo del jugador
|
// Pinta rectangulo del jugador
|
||||||
SDL_SetRenderDrawColor(renderer, debug_color_.r, debug_color_.g, debug_color_.b, 192);
|
|
||||||
SDL_Rect rect = getRect();
|
SDL_Rect rect = getRect();
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
surface->drawRectBorder(&rect, static_cast<Uint8>(PaletteColor::BRIGHT_CYAN));
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 255, 255, 255);
|
|
||||||
SDL_RenderDrawRect(renderer, &rect);
|
|
||||||
|
|
||||||
// Pinta el rectangulo de movimiento
|
// Pinta el rectangulo de movimiento
|
||||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
|
||||||
if (vx_ != 0.0f)
|
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)
|
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
|
// Pinta el punto de debug
|
||||||
SDL_SetRenderDrawColor(renderer, rand() % 256, rand() % 256, rand() % 256, 255);
|
surface->putPixel(debug_point_.x, debug_point_.y, rand() % 16);
|
||||||
SDL_RenderDrawPoint(renderer, debug_point_.x, debug_point_.y);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif // DEBUG
|
||||||
@@ -89,7 +89,7 @@ public:
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
SDL_Rect debug_rect_x_; // Rectangulo de desplazamiento para el modo 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
|
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
|
SDL_Point debug_point_; // Punto para debug
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
132
source/room.cpp
132
source/room.cpp
@@ -497,86 +497,74 @@ void Room::fillMapTexture()
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (Debug::get()->getEnabled())
|
if (Debug::get()->getEnabled())
|
||||||
{ /*
|
{
|
||||||
// BottomSurfaces
|
auto surface = Screen::get()->getRendererSurface();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TopSurfaces
|
// BottomSurfaces
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
for (auto l : top_floors_)
|
for (auto l : bottom_floors_)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::BLUE));
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 0, 0xFF);
|
}
|
||||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LeftSurfaces
|
// TopSurfaces
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
for (auto l : left_walls_)
|
for (auto l : top_floors_)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::RED));
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 128, 128, 255, 0xFF);
|
}
|
||||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x, l.y1, l.x, l.y2);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RightSurfaces
|
// LeftSurfaces
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
for (auto l : right_walls_)
|
for (auto l : left_walls_)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::GREEN));
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 255, 0, 0xFF);
|
}
|
||||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x, l.y1, l.x, l.y2);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LeftSlopes
|
// RightSurfaces
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
for (auto l : left_slopes_)
|
for (auto l : right_walls_)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::MAGENTA));
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 255, 0xFF);
|
}
|
||||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y1, l.x2, l.y2);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RightSlopes
|
// LeftSlopes
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
for (auto l : right_slopes_)
|
for (auto l : left_slopes_)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::CYAN));
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 0, 255, 0xFF);
|
}
|
||||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y1, l.x2, l.y2);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AutoSurfaces
|
// RightSlopes
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
for (auto l : conveyor_belt_floors_)
|
for (auto l : right_slopes_)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::YELLOW));
|
||||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
*/
|
// AutoSurfaces
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
for (auto l : conveyor_belt_floors_)
|
||||||
|
{
|
||||||
|
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::WHITE));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // DEBUG
|
||||||
Screen::get()->setRendererSurface(previuos_renderer);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user