From f14388530ddcdb6b836f01dd74157b514479c9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Sat, 2 Jul 2022 23:25:26 +0200 Subject: [PATCH] Ya casi dibuja el mapa --- source/game.cpp | 6 +++--- source/room.cpp | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/game.cpp b/source/game.cpp index c7420722..d8e2dd82 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -105,11 +105,11 @@ section_t Game::run() mRoom->draw(); // Escribe las medidas de ancho y alto de la pantalla - mText->writeCentered(GAMECANVAS_CENTER_X, 0, std::to_string(GAMECANVAS_WIDTH), -1); - mText->write(0, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), std::to_string(GAMECANVAS_HEIGHT), -1); + // mText->writeCentered(GAMECANVAS_CENTER_X, 0, std::to_string(GAMECANVAS_WIDTH), -1); + // mText->write(0, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), std::to_string(GAMECANVAS_HEIGHT), -1); // Texto en el centro de la pantalla - mText->writeCentered(GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), mRoom->getName(), -1); + mText->writeCentered(GAMECANVAS_CENTER_X, 18 * 8, mRoom->getName(), -1); // Actualiza la pantalla mScreen->blit(); diff --git a/source/room.cpp b/source/room.cpp index 1833ecd8..a3d6d9c1 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -161,8 +161,12 @@ color_t Room::getBGColor() // Dibuja la habitación en pantalla void Room::draw() { - int x = 0; - int y = 0; SDL_Rect clip = {0, 0, 8, 8}; - texture->render(renderer,x, y, &clip); + for (int y = 0; y < 16; y++) + for (int x = 0; x < 32; x++) + { + clip.x = tilemap[(y * 16) + x] * 8; + clip.y = tilemap[(y * 16) + x] * 8; + texture->render(renderer, x * 8, y * 8, &clip); + } } \ No newline at end of file