diff --git a/source/common/utils.h b/source/common/utils.h index 4a5c892..5e8778e 100644 --- a/source/common/utils.h +++ b/source/common/utils.h @@ -61,6 +61,14 @@ struct section_t Uint8 subsection; }; +// Estructura para albergar trucos +struct cheat_t +{ + bool infiniteLives; // Indica si el jugador dispone de vidas infinitas + bool invincible; // Indica si el jugador puede morir + bool jailEnabled; // Indica si la Jail está abierta +}; + // Estructura con todas las opciones de configuración del programa struct options_t { @@ -76,8 +84,7 @@ struct options_t float borderSize; // Porcentaje de borde que se añade a lo ventana palette_e palette; // Paleta de colores a usar en el juego bool console; // Indica si ha de mostrar información por la consola de texto - bool infiniteLives; // Indica si el jugador dispone de vidas infinitas - bool invincible; // Indica si el jugador puede morir + cheat_t cheat; // Contiene trucos y ventajas para el juego }; // Calcula el cuadrado de la distancia entre dos puntos diff --git a/source/director.cpp b/source/director.cpp index 93880b8..c5d9a97 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -9,7 +9,7 @@ Director::Director(int argc, char *argv[]) section.name = SECTION_PROG_LOGO; section.subsection = SUBSECTION_LOGO_TO_INTRO; - section.name = SECTION_PROG_GAME; + //section.name = SECTION_PROG_GAME; // Crea e inicializa las opciones del programa iniOptions(); @@ -85,8 +85,9 @@ void Director::iniOptions() // Estos valores no se guardan en el fichero de configuraci´ón options->console = false; - options->infiniteLives = false; - options->invincible = false; + options->cheat.infiniteLives = false; + options->cheat.invincible = false; + options->cheat.jailEnabled = false; } // Comprueba los parametros del programa @@ -105,12 +106,17 @@ void Director::checkProgramArguments(int argc, char *argv[]) else if (strcmp(argv[i], "--infiniteLives") == 0) { - options->infiniteLives = true; + options->cheat.infiniteLives = true; } else if (strcmp(argv[i], "--invincible") == 0) { - options->invincible = true; + options->cheat.invincible = true; + } + + else if (strcmp(argv[i], "--jailEnabled") == 0) + { + options->cheat.jailEnabled = true; } } } diff --git a/source/game.cpp b/source/game.cpp index 67a993a..7bc1d21 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -19,7 +19,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as this->options = options; // **** - currentRoom = "01.room"; + currentRoom = "03.room"; const int x = 29; const int y = 13; spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL}; @@ -44,7 +44,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as board.items = 0; board.rooms = 1; board.music = true; - board.jailEnabled = false; + board.jailEnabled = options->cheat.jailEnabled; setScoreBoardColor(); roomTracker->addRoom(currentRoom); paused = false; @@ -95,7 +95,7 @@ void Game::checkEventHandler() case SDL_SCANCODE_D: debug->switchEnabled(); - options->invincible = debug->getEnabled(); + options->cheat.invincible = debug->getEnabled(); board.music = !debug->getEnabled(); board.music ? JA_ResumeMusic() : JA_PauseMusic(); break; @@ -379,13 +379,13 @@ void Game::checkGameOver() // Mata al jugador void Game::killPlayer() { - if (options->invincible) + if (options->cheat.invincible) { return; } // Resta una vida al jugador - if (!options->infiniteLives) + if (!options->cheat.infiniteLives) { board.lives--; }