Añadidos nuevos trucos

This commit is contained in:
2022-11-06 15:00:03 +01:00
parent 0cb83657be
commit bf59cc01e4
3 changed files with 25 additions and 12 deletions

View File

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

View File

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

View File

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