Todavía falla MUCHO con las rampas

This commit is contained in:
2022-09-06 21:25:41 +02:00
parent 9af135100c
commit 247e0060ee
5 changed files with 21 additions and 12 deletions

View File

@@ -31,11 +31,18 @@ void Debug::update()
void Debug::render() void Debug::render()
{ {
int y = this->y; int y = this->y;
int w = 0;
for (auto s : slot) for (auto s : slot)
{ {
text->write(x, y, s); text->write(x, y, s);
w = (std::max(w, (int)s.length()));
y += text->getCharacterSize() + 1; y += text->getCharacterSize() + 1;
if (y > 192 - text->getCharacterSize())
{
y = this->y;
x += w*text->getCharacterSize() + 2;
}
} }
} }

View File

@@ -192,9 +192,11 @@ void Game::render()
// Pasa la información de debug // Pasa la información de debug
void Game::updateDebugInfo() void Game::updateDebugInfo()
{ {
debug->add("MIRA! MIRA ELS SLOTS!");
debug->add("X = " + std::to_string((int)player->x) + ", Y = " + std::to_string((int)player->y)); debug->add("X = " + std::to_string((int)player->x) + ", Y = " + std::to_string((int)player->y));
debug->add("VX = " + std::to_string(player->vx) + ", VY = " + std::to_string(player->vy)); debug->add("VX = " + std::to_string(player->vx).substr(0,4) + ", VY = " + std::to_string(player->vy).substr(0,4));
debug->add("STATE = " + std::to_string(player->state)); debug->add("STATE = " + std::to_string(player->state));
debug->add("VEUS??");
} }
// Pone la información de debug en pantalla // Pone la información de debug en pantalla
@@ -206,7 +208,7 @@ void Game::renderDebugInfo()
} }
// Borra el marcador // Borra el marcador
SDL_Rect rect = {0, 17 * 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(renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
@@ -227,7 +229,7 @@ void Game::renderDebugInfo()
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
// Pinta el texto // Pinta el texto
debug->setPos({1, 17 * 8}); debug->setPos({1, 18 * 8});
debug->render(); debug->render();
} }
@@ -235,12 +237,12 @@ void Game::renderDebugInfo()
void Game::renderRoomName() void Game::renderRoomName()
{ {
// Texto en el centro de la pantalla // Texto en el centro de la pantalla
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK}; SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
color_t color = stringToColor("bright_black"); color_t color = stringToColor("white");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF); SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
text->writeCentered(GAMECANVAS_CENTER_X, 16 * 8, room->getName()); text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 16 * 8 + 4, room->getName(), 1, room->getBGColor());
} }
// Cambia de habitación // Cambia de habitación

View File

@@ -238,9 +238,10 @@ void Player::move()
} }
} }
// Comprueba colisiones con rampas // Comprueba colisiones con rampas solo si esta quieto o cayendo
else else if (vy >= 0.0f)
{ {
tile_e slope = checkSlopes(); tile_e slope = checkSlopes();
tile_e slope2 = checkSlopes2(); tile_e slope2 = checkSlopes2();
debug->add("SLOPE = " + std::to_string(slope)); debug->add("SLOPE = " + std::to_string(slope));

View File

@@ -130,7 +130,6 @@ public:
// Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile // Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile
int getSlopeHeight(SDL_Point p, tile_e slope); int getSlopeHeight(SDL_Point p, tile_e slope);
}; };
#endif #endif

View File

@@ -78,12 +78,12 @@ ScoreBoard::~ScoreBoard()
void ScoreBoard::render() void ScoreBoard::render()
{ {
// Dibuja el fondo del marcador // Dibuja el fondo del marcador
const SDL_Rect rect = {0, 17 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT}; const SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
// Dibuja las vidas // Dibuja las vidas
sprite->setPosY(18 * BLOCK); sprite->setPosY(19 * BLOCK);
int index; int index;
const int desp = (counter / 40) % 8; const int desp = (counter / 40) % 8;
const int frame = desp % 4; const int frame = desp % 4;
@@ -108,7 +108,7 @@ void ScoreBoard::render()
std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10); std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10);
std::string text = "Items collected " + itemsTxt + " Time " + timeTxt; std::string text = "Items collected " + itemsTxt + " Time " + timeTxt;
const color_t color = stringToColor("white"); const color_t color = stringToColor("white");
this->text->writeColored(BLOCK, 21 * BLOCK, text, color); this->text->writeColored(BLOCK, 22 * BLOCK, text, color);
} }
// Actualiza las variables del objeto // Actualiza las variables del objeto