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()
{
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;
}
}
}

View File

@@ -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

View File

@@ -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));

View File

@@ -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

View File

@@ -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