From 61b19a56990982c57f5b616081936ad521047c5f Mon Sep 17 00:00:00 2001 From: Sergio Valor Martinez Date: Mon, 7 Nov 2022 13:59:06 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adido=20movimiento=20por=20las=20habitac?= =?UTF-8?q?iones=20con=20WASD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/game.cpp | 28 +++++++++++++++++++++++++++- source/game.h | 3 +++ source/room.cpp | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/source/game.cpp b/source/game.cpp index aeb1b5f..fadae21 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -93,7 +93,7 @@ void Game::checkEventHandler() section.name = SECTION_PROG_TITLE; break; - case SDL_SCANCODE_D: + case SDL_SCANCODE_G: debug->switchEnabled(); options->cheat.invincible = debug->getEnabled(); board.music = !debug->getEnabled(); @@ -160,6 +160,22 @@ void Game::checkEventHandler() switchPalette(); break; + case SDL_SCANCODE_W: + goToRoom(BORDER_TOP); + break; + + case SDL_SCANCODE_A: + goToRoom(BORDER_LEFT); + break; + + case SDL_SCANCODE_S: + goToRoom(BORDER_BOTTOM); + break; + + case SDL_SCANCODE_D: + goToRoom(BORDER_RIGHT); + break; + default: break; } @@ -535,4 +551,14 @@ int Game::getTotalItems() } return items; +} + +// Va a la habitación designada +void Game::goToRoom(int border) +{ + const std::string roomName = room->getRoom(border); + if (changeRoom(roomName)) + { + currentRoom = roomName; + } } \ No newline at end of file diff --git a/source/game.h b/source/game.h index c048e61..427102e 100644 --- a/source/game.h +++ b/source/game.h @@ -117,6 +117,9 @@ private: // Obtiene la cantidad total de items que hay en el mapeado del juego int getTotalItems(); + // Va a la habitación designada + void goToRoom(int border); + public: // Constructor Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug); diff --git a/source/room.cpp b/source/room.cpp index a1387dc..ea9a47d 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -588,7 +588,7 @@ void Room::fillMapTexture() for (auto l : leftSurfaces) { SDL_SetRenderDrawColor(renderer, (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF); - SDL_SetRenderDrawColor(renderer, 0, 0, 255, 0xFF); + SDL_SetRenderDrawColor(renderer, 128, 128, 255, 0xFF); SDL_RenderDrawLine(renderer, l.x, l.y1, l.x, l.y2); } }