Añadido movimiento por las habitaciones con WASD

This commit is contained in:
2022-11-07 13:59:06 +01:00
parent 81eeb1776a
commit 61b19a5699
3 changed files with 31 additions and 2 deletions

View File

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

View File

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

View File

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