diff --git a/source/debug.cpp b/source/debug.cpp index 76940c8..4a6c7aa 100644 --- a/source/debug.cpp +++ b/source/debug.cpp @@ -31,11 +31,18 @@ void Debug::update() void Debug::render() { int y = this->y; + int w = 0; for (auto s : slot) { text->write(x, y, s); + w = (std::max(w, (int)s.length())); y += text->getCharacterSize() + 1; + if (y > 192 - text->getCharacterSize()) + { + y = this->y; + x += w*text->getCharacterSize() + 2; + } } } diff --git a/source/game.cpp b/source/game.cpp index f71c37b..e2f568a 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -192,9 +192,11 @@ void Game::render() // Pasa la información de debug 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("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("VEUS??"); } // Pone la información de debug en pantalla @@ -206,7 +208,7 @@ void Game::renderDebugInfo() } // 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_RenderFillRect(renderer, &rect); @@ -227,7 +229,7 @@ void Game::renderDebugInfo() SDL_RenderFillRect(renderer, &rect); // Pinta el texto - debug->setPos({1, 17 * 8}); + debug->setPos({1, 18 * 8}); debug->render(); } @@ -235,12 +237,12 @@ void Game::renderDebugInfo() void Game::renderRoomName() { // Texto en el centro de la pantalla - SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK}; - color_t color = stringToColor("bright_black"); + SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2}; + color_t color = stringToColor("white"); SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF); 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 diff --git a/source/player.cpp b/source/player.cpp index 5845f0c..3d8474e 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -238,9 +238,10 @@ void Player::move() } } - // Comprueba colisiones con rampas - else + // Comprueba colisiones con rampas solo si esta quieto o cayendo + else if (vy >= 0.0f) { + tile_e slope = checkSlopes(); tile_e slope2 = checkSlopes2(); debug->add("SLOPE = " + std::to_string(slope)); diff --git a/source/room.h b/source/room.h index abd4550..612b5f9 100644 --- a/source/room.h +++ b/source/room.h @@ -130,7 +130,6 @@ public: // Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile int getSlopeHeight(SDL_Point p, tile_e slope); - }; #endif diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index b098d82..77dedce 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -78,12 +78,12 @@ ScoreBoard::~ScoreBoard() void ScoreBoard::render() { // 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_RenderFillRect(renderer, &rect); // Dibuja las vidas - sprite->setPosY(18 * BLOCK); + sprite->setPosY(19 * BLOCK); int index; const int desp = (counter / 40) % 8; 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 text = "Items collected " + itemsTxt + " Time " + timeTxt; 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