Eliminat el punter a "section"

This commit is contained in:
2024-09-28 09:28:22 +02:00
parent 0a8d0479a0
commit 8d263931b2
19 changed files with 191 additions and 172 deletions

View File

@@ -10,24 +10,7 @@
#define PLAY_AREA_LEFT 0 #define PLAY_AREA_LEFT 0
#define PLAY_AREA_TOP 0 #define PLAY_AREA_TOP 0
// Secciones del programa
#define SECTION_PROG_INIT 8
#define SECTION_PROG_LOGO 0
#define SECTION_PROG_INTRO 1
#define SECTION_PROG_TITLE 2
#define SECTION_PROG_GAME 3
#define SECTION_PROG_HI_SCORE_TABLE 4
#define SECTION_PROG_GAME_DEMO 5
#define SECTION_PROG_INSTRUCTIONS 6
#define SECTION_PROG_QUIT 7
// Subsecciones
#define SECTION_OPTIONS_GAME_PLAY_1P 0
#define SECTION_OPTIONS_GAME_PLAY_2P 1
#define SECTION_OPTIONS_TITLE_1 3
#define SECTION_OPTIONS_TITLE_2 4
#define SECTION_OPTIONS_QUIT_NORMAL 5
#define SECTION_OPTIONS_QUIT_SHUTDOWN 6
// Ningun tipo // Ningun tipo
#define NO_KIND 0 #define NO_KIND 0

View File

@@ -1,14 +1,14 @@
#include "define_buttons.h" #include "define_buttons.h"
#include "param.h" #include "param.h"
#include "options.h" #include "options.h"
#include "section.h"
// Constructor // Constructor
DefineButtons::DefineButtons(Input *input, Text *text, section_t *section) DefineButtons::DefineButtons(Input *input, Text *text)
{ {
// Copia punteros a los objetos // Copia punteros a los objetos
this->input = input; this->input = input;
this->text = text; this->text = text;
this->section = section;
// Inicializa variables // Inicializa variables
enabled = false; enabled = false;
@@ -112,7 +112,8 @@ void DefineButtons::checkInput()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (event.type == SDL_QUIT) if (event.type == SDL_QUIT)
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
section::options = section::OPTIONS_QUIT_NORMAL;
break; break;
} }

View File

@@ -22,7 +22,6 @@ private:
Text *text; // Objeto para escribir texto Text *text; // Objeto para escribir texto
// Variables // Variables
section_t *section; // Indicador para el bucle del titulo
bool enabled; // Indica si el objeto está habilitado bool enabled; // Indica si el objeto está habilitado
int x; // Posición donde dibujar el texto int x; // Posición donde dibujar el texto
int y; // Posición donde dibujar el texto int y; // Posición donde dibujar el texto
@@ -45,7 +44,7 @@ private:
public: public:
// Constructor // Constructor
DefineButtons(Input *input, Text *text, section_t *section); DefineButtons(Input *input, Text *text);
// Destructor // Destructor
~DefineButtons(); ~DefineButtons();

View File

@@ -2,6 +2,7 @@
#include "utils.h" #include "utils.h"
#include "const.h" #include "const.h"
#include "options.h" #include "options.h"
#include "section.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string> #include <string>
@@ -16,15 +17,13 @@
// Constructor // Constructor
Director::Director(int argc, char *argv[]) Director::Director(int argc, char *argv[])
{ {
// Inicializa variables
section = new section_t();
#ifdef RECORDING #ifdef RECORDING
section->name = SECTION_PROG_GAME; section::name = section::NAME_GAME;
section->options = SECTION_OPTIONS_GAME_PLAY_1P; section::options = section::OPTIONS_GAME_PLAY_1P;
#elif DEBUG #elif DEBUG
section->name = SECTION_PROG_LOGO; section::name = section::NAME_LOGO;
#else #else
section->name = SECTION_PROG_LOGO; section::name = section::NAME_LOGO;
#endif #endif
// Comprueba los parametros del programa // Comprueba los parametros del programa
@@ -90,7 +89,6 @@ Director::~Director()
delete asset; delete asset;
delete input; delete input;
delete screen; delete screen;
delete section;
deleteSounds(); deleteSounds();
deleteMusics(); deleteMusics();
@@ -602,7 +600,7 @@ void Director::deleteMusics()
// Ejecuta la sección con el logo // Ejecuta la sección con el logo
void Director::runLogo() void Director::runLogo()
{ {
logo = new Logo(screen, asset, input, section); logo = new Logo(screen, asset, input);
logo->run(); logo->run();
delete logo; delete logo;
} }
@@ -610,7 +608,7 @@ void Director::runLogo()
// Ejecuta la sección con la secuencia de introducción // Ejecuta la sección con la secuencia de introducción
void Director::runIntro() void Director::runIntro()
{ {
intro = new Intro(screen, asset, input, section, getMusic(musics, "intro.ogg")); intro = new Intro(screen, asset, input, getMusic(musics, "intro.ogg"));
intro->run(); intro->run();
delete intro; delete intro;
} }
@@ -618,7 +616,7 @@ void Director::runIntro()
// Ejecuta la sección con el titulo del juego // Ejecuta la sección con el titulo del juego
void Director::runTitle() void Director::runTitle()
{ {
title = new Title(screen, asset, input, section, getMusic(musics, "title.ogg")); title = new Title(screen, asset, input, getMusic(musics, "title.ogg"));
title->run(); title->run();
delete title; delete title;
} }
@@ -626,9 +624,9 @@ void Director::runTitle()
// Ejecuta la sección donde se juega al juego // Ejecuta la sección donde se juega al juego
void Director::runGame() void Director::runGame()
{ {
const int playerID = section->options; const int playerID = section::options;
const int currentStage = 0; const int currentStage = 0;
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, section, getMusic(musics, "playing.ogg")); game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, getMusic(musics, "playing.ogg"));
game->run(); game->run();
delete game; delete game;
} }
@@ -636,7 +634,7 @@ void Director::runGame()
// Ejecuta la sección donde se muestran las instrucciones // Ejecuta la sección donde se muestran las instrucciones
void Director::runInstructions() void Director::runInstructions()
{ {
instructions = new Instructions(screen, asset, input, section, getMusic(musics, "title.ogg")); instructions = new Instructions(screen, asset, input, getMusic(musics, "title.ogg"));
instructions->run(); instructions->run();
delete instructions; delete instructions;
} }
@@ -644,7 +642,7 @@ void Director::runInstructions()
// Ejecuta la sección donde se muestra la tabla de puntuaciones // Ejecuta la sección donde se muestra la tabla de puntuaciones
void Director::runHiScoreTable() void Director::runHiScoreTable()
{ {
hiScoreTable = new HiScoreTable(screen, asset, input, section, getMusic(musics, "title.ogg")); hiScoreTable = new HiScoreTable(screen, asset, input, getMusic(musics, "title.ogg"));
hiScoreTable->run(); hiScoreTable->run();
delete hiScoreTable; delete hiScoreTable;
} }
@@ -654,7 +652,7 @@ void Director::runDemoGame()
{ {
const int playerID = (rand() % 2) + 1; const int playerID = (rand() % 2) + 1;
const int currentStage = 0; const int currentStage = 0;
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, screen, asset, input, section, nullptr); demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, screen, asset, input, nullptr);
demoGame->run(); demoGame->run();
delete demoGame; delete demoGame;
} }
@@ -662,45 +660,48 @@ void Director::runDemoGame()
int Director::run() int Director::run()
{ {
// Bucle principal // Bucle principal
while (section->name != SECTION_PROG_QUIT) while (section::name != section::NAME_QUIT)
{ {
switch (section->name) switch (section::name)
{ {
case SECTION_PROG_INIT: case section::NAME_INIT:
section->name = SECTION_PROG_LOGO; section::name = section::NAME_LOGO;
break; break;
case SECTION_PROG_LOGO: case section::NAME_LOGO:
runLogo(); runLogo();
break; break;
case SECTION_PROG_INTRO: case section::NAME_INTRO:
runIntro(); runIntro();
break; break;
case SECTION_PROG_TITLE: case section::NAME_TITLE:
runTitle(); runTitle();
break; break;
case SECTION_PROG_GAME: case section::NAME_GAME:
runGame(); runGame();
break; break;
case SECTION_PROG_HI_SCORE_TABLE: case section::NAME_HI_SCORE_TABLE:
runHiScoreTable(); runHiScoreTable();
break; break;
case SECTION_PROG_GAME_DEMO: case section::NAME_GAME_DEMO:
runDemoGame(); runDemoGame();
break; break;
case SECTION_PROG_INSTRUCTIONS: case section::NAME_INSTRUCTIONS:
runInstructions(); runInstructions();
break; break;
default:
break;
} }
} }
const int returnCode = section->options == SECTION_OPTIONS_QUIT_NORMAL ? 0 : 1; const int returnCode = section::options == section::OPTIONS_QUIT_NORMAL ? 0 : 1;
return returnCode; return returnCode;
} }

View File

@@ -38,7 +38,6 @@ private:
Game *demoGame; // Objeto para lanzar la demo del juego Game *demoGame; // Objeto para lanzar la demo del juego
Input *input; // Objeto Input para gestionar las entradas Input *input; // Objeto Input para gestionar las entradas
Asset *asset; // Objeto que gestiona todos los ficheros de recursos Asset *asset; // Objeto que gestiona todos los ficheros de recursos
section_t *section; // Sección y subsección actual del programa;
// Variables // Variables
std::string executablePath; // Path del ejecutable std::string executablePath; // Path del ejecutable

View File

@@ -5,13 +5,12 @@
#define GAME_OVER_COUNTER 350 #define GAME_OVER_COUNTER 350
// Constructor // Constructor
Game::Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music) Game::Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, JA_Music_t *music)
{ {
// Copia los punteros // Copia los punteros
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->input = input; this->input = input;
this->section = section;
this->music = music; this->music = music;
renderer = screen->getRenderer(); renderer = screen->getRenderer();
@@ -176,8 +175,8 @@ void Game::init(int playerID)
paused = false; paused = false;
gameCompleted = false; gameCompleted = false;
gameCompletedCounter = 0; gameCompletedCounter = 0;
section->name = SECTION_PROG_GAME; section::name = section::NAME_GAME;
section->options = SECTION_OPTIONS_GAME_PLAY_1P; section::options = section::OPTIONS_GAME_PLAY_1P;
currentPower = 0; currentPower = 0;
menaceCurrent = 0; menaceCurrent = 0;
menaceThreshold = 0; menaceThreshold = 0;
@@ -948,7 +947,7 @@ void Game::updateGameOver()
if (fade->hasEnded()) if (fade->hasEnded())
{ {
section->name = SECTION_PROG_HI_SCORE_TABLE; section::name = section::NAME_HI_SCORE_TABLE;
} }
} }
} }
@@ -1831,7 +1830,7 @@ void Game::update()
// Si ha terminado el fundido, cambia de sección // Si ha terminado el fundido, cambia de sección
if (fade->hasEnded()) if (fade->hasEnded())
{ {
section->name = SECTION_PROG_HI_SCORE_TABLE; section::name = section::NAME_HI_SCORE_TABLE;
return; return;
} }
} }
@@ -1849,7 +1848,7 @@ void Game::update()
// Si se ha llenado el vector con datos, sale del programa // Si se ha llenado el vector con datos, sale del programa
else else
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
return; return;
} }
#endif #endif
@@ -2037,7 +2036,7 @@ void Game::checkInput()
// Comprueba si se sale con el teclado // Comprueba si se sale con el teclado
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
quit(SECTION_OPTIONS_QUIT_NORMAL); quit(section::OPTIONS_QUIT_NORMAL);
return; return;
} }
@@ -2046,14 +2045,14 @@ void Game::checkInput()
// Comprueba si se sale con el mando // Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
quit(SECTION_OPTIONS_QUIT_SHUTDOWN); quit(section::OPTIONS_QUIT_SHUTDOWN);
return; return;
} }
// Comprueba si se va a resetear el juego // Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
section->name = SECTION_PROG_LOGO; section::name = section::NAME_LOGO;
screen->showNotification("Reset"); screen->showNotification("Reset");
return; return;
} }
@@ -2134,7 +2133,7 @@ void Game::checkInput()
// Si se pulsa cualquier tecla, se sale del modo demo // Si se pulsa cualquier tecla, se sale del modo demo
if (input->checkAnyButtonPressed()) if (input->checkAnyButtonPressed())
{ {
section->name = SECTION_PROG_TITLE; section::name = section::NAME_TITLE;
return; return;
} }
} }
@@ -2376,7 +2375,7 @@ void Game::checkMusicStatus()
// Bucle para el juego // Bucle para el juego
void Game::run() void Game::run()
{ {
while (section->name == SECTION_PROG_GAME) while (section::name == section::NAME_GAME)
{ {
#ifndef RECORDING #ifndef RECORDING
checkInput(); checkInput();
@@ -2503,9 +2502,9 @@ void Game::updateGameCompleted()
if (gameCompletedCounter == GAME_COMPLETED_END) if (gameCompletedCounter == GAME_COMPLETED_END)
{ {
// section->options = SUBSECTION_GAME_GAMEOVER; // section::options = SUBSECTION_GAME_GAMEOVER;
section->name = SECTION_PROG_TITLE; section::name = section::NAME_TITLE;
section->options = SECTION_OPTIONS_TITLE_1; section::options = section::OPTIONS_TITLE_1;
} }
} }
@@ -2563,7 +2562,7 @@ void Game::checkEvents()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
break; break;
} }
@@ -2815,12 +2814,12 @@ int Game::getController(int playerId)
} }
// Termina // Termina
void Game::quit(int code) void Game::quit(section::options_e code)
{ {
if (screen->notificationsAreActive()) if (screen->notificationsAreActive())
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
section->options = code; section::options = code;
} }
else else
{ {

View File

@@ -22,6 +22,7 @@
#include "manage_hiscore_table.h" #include "manage_hiscore_table.h"
#include "explosions.h" #include "explosions.h"
#include "enemy_formations.h" #include "enemy_formations.h"
#include "section.h"
#include <iostream> #include <iostream>
#define GAME_MODE_DEMO_OFF false #define GAME_MODE_DEMO_OFF false
@@ -107,7 +108,6 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla Screen *screen; // Objeto encargado de dibujar en pantalla
Asset *asset; // Objeto que gestiona todos los ficheros de recursos Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Manejador de entrada Input *input; // Manejador de entrada
section_t *section; // Seccion actual dentro del juego
Scoreboard *scoreboard; // Objeto para dibujar el marcador Scoreboard *scoreboard; // Objeto para dibujar el marcador
Background *background; // Objeto para dibujar el fondo del juego Background *background; // Objeto para dibujar el fondo del juego
Explosions *explosions; // Objeto para dibujar explosiones Explosions *explosions; // Objeto para dibujar explosiones
@@ -444,11 +444,11 @@ private:
int getController(int playerId); int getController(int playerId);
// Termina // Termina
void quit(int code); void quit(section::options_e code);
public: public:
// Constructor // Constructor
Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music); Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, JA_Music_t *music);
// Destructor // Destructor
~Game(); ~Game();

View File

@@ -4,13 +4,12 @@
#include <iostream> #include <iostream>
// Constructor // Constructor
HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music) HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, JA_Music_t *music)
{ {
// Copia punteros // Copia punteros
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->input = input; this->input = input;
this->section = section;
this->music = music; this->music = music;
renderer = screen->getRenderer(); renderer = screen->getRenderer();
@@ -25,7 +24,7 @@ HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, section_t
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND); SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
// Inicializa variables // Inicializa variables
section->name = SECTION_PROG_HI_SCORE_TABLE; section::name = section::NAME_HI_SCORE_TABLE;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
counter = 0; counter = 0;
@@ -175,7 +174,7 @@ void HiScoreTable::checkEvents()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
break; break;
} }
@@ -196,7 +195,7 @@ void HiScoreTable::checkInput()
// Comprueba si se sale con el teclado // Comprueba si se sale con el teclado
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
quit(SECTION_OPTIONS_QUIT_NORMAL); quit(section::OPTIONS_QUIT_NORMAL);
return; return;
} }
@@ -204,8 +203,8 @@ void HiScoreTable::checkInput()
if (input->checkAnyButtonPressed()) if (input->checkAnyButtonPressed())
{ {
JA_StopMusic(); JA_StopMusic();
section->name = SECTION_PROG_TITLE; section::name = section::NAME_TITLE;
section->options = SECTION_OPTIONS_TITLE_1; section::options = section::OPTIONS_TITLE_1;
return; return;
} }
@@ -214,14 +213,14 @@ void HiScoreTable::checkInput()
// Comprueba si se sale con el mando // Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
quit(SECTION_OPTIONS_QUIT_SHUTDOWN); quit(section::OPTIONS_QUIT_SHUTDOWN);
return; return;
} }
// Comprueba si se va a resetear el juego // Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
section->name = SECTION_PROG_LOGO; section::name = section::NAME_LOGO;
screen->showNotification("Reset"); screen->showNotification("Reset");
return; return;
} }
@@ -244,7 +243,7 @@ void HiScoreTable::checkInput()
// Bucle para la pantalla de instrucciones // Bucle para la pantalla de instrucciones
void HiScoreTable::run() void HiScoreTable::run()
{ {
while (section->name == SECTION_PROG_HI_SCORE_TABLE) while (section::name == section::NAME_HI_SCORE_TABLE)
{ {
checkInput(); checkInput();
update(); update();
@@ -308,7 +307,7 @@ void HiScoreTable::updateFade()
if (fade->hasEnded() && fadeMode == FADE_OUT) if (fade->hasEnded() && fadeMode == FADE_OUT)
{ {
section->name = SECTION_PROG_INSTRUCTIONS; section::name = section::NAME_INSTRUCTIONS;
} }
} }
@@ -337,12 +336,12 @@ std::string HiScoreTable::format(int number)
} }
// Termina // Termina
void HiScoreTable::quit(int code) void HiScoreTable::quit(section::options_e code)
{ {
if (screen->notificationsAreActive()) if (screen->notificationsAreActive())
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
section->options = code; section::options = code;
} }
else else
{ {

View File

@@ -12,6 +12,7 @@
#include "lang.h" #include "lang.h"
#include "fade.h" #include "fade.h"
#include "background.h" #include "background.h"
#include "section.h"
/* /*
Esta clase gestiona un estado del programa. Se encarga de mostrar la tabla con las puntuaciones Esta clase gestiona un estado del programa. Se encarga de mostrar la tabla con las puntuaciones
@@ -38,7 +39,6 @@ private:
Fade *fade; // Objeto para renderizar fades Fade *fade; // Objeto para renderizar fades
Text *text; // Objeto para escribir texto Text *text; // Objeto para escribir texto
JA_Music_t *music; // Musica de fondo JA_Music_t *music; // Musica de fondo
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables // Variables
Uint16 counter; // Contador Uint16 counter; // Contador
@@ -76,11 +76,11 @@ private:
void updateFade(); void updateFade();
// Termina // Termina
void quit(int code); void quit(section::options_e code);
public: public:
// Constructor // Constructor
HiScoreTable(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music); HiScoreTable(Screen *screen, Asset *asset, Input *input, JA_Music_t *music);
// Destructor // Destructor
~HiScoreTable(); ~HiScoreTable();

View File

@@ -4,13 +4,12 @@
#include <iostream> #include <iostream>
// Constructor // Constructor
Instructions::Instructions(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music) Instructions::Instructions(Screen *screen, Asset *asset, Input *input, JA_Music_t *music)
{ {
// Copia los punteros // Copia los punteros
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->input = input; this->input = input;
this->section = section;
this->music = music; this->music = music;
renderer = screen->getRenderer(); renderer = screen->getRenderer();
@@ -29,7 +28,7 @@ Instructions::Instructions(Screen *screen, Asset *asset, Input *input, section_t
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
// Inicializa variables // Inicializa variables
section->name = SECTION_PROG_INSTRUCTIONS; section::name = section::NAME_INSTRUCTIONS;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
counter = 0; counter = 0;
@@ -252,8 +251,8 @@ void Instructions::update()
// Comprueba si el contador ha llegado al final // Comprueba si el contador ha llegado al final
if (counter == counterEnd) if (counter == counterEnd)
{ {
section->name = SECTION_PROG_TITLE; section::name = section::NAME_TITLE;
section->options = SECTION_OPTIONS_TITLE_1; section::options = section::OPTIONS_TITLE_1;
} }
} }
} }
@@ -305,7 +304,7 @@ void Instructions::checkEvents()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
break; break;
} }
@@ -326,7 +325,7 @@ void Instructions::checkInput()
// Comprueba si se sale con el teclado // Comprueba si se sale con el teclado
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
quit(SECTION_OPTIONS_QUIT_NORMAL); quit(section::OPTIONS_QUIT_NORMAL);
return; return;
} }
@@ -334,8 +333,8 @@ void Instructions::checkInput()
if (input->checkAnyButtonPressed()) if (input->checkAnyButtonPressed())
{ {
JA_StopMusic(); JA_StopMusic();
section->name = SECTION_PROG_TITLE; section::name = section::NAME_TITLE;
section->options = SECTION_OPTIONS_TITLE_1; section::options = section::OPTIONS_TITLE_1;
return; return;
} }
@@ -344,14 +343,14 @@ void Instructions::checkInput()
// Comprueba si se sale con el mando // Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
quit(SECTION_OPTIONS_QUIT_SHUTDOWN); quit(section::OPTIONS_QUIT_SHUTDOWN);
return; return;
} }
// Comprueba si se va a resetear el juego // Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
section->name = SECTION_PROG_LOGO; section::name = section::NAME_LOGO;
screen->showNotification("Reset"); screen->showNotification("Reset");
return; return;
} }
@@ -374,7 +373,7 @@ void Instructions::checkInput()
// Bucle para la pantalla de instrucciones // Bucle para la pantalla de instrucciones
void Instructions::run() void Instructions::run()
{ {
while (section->name == SECTION_PROG_INSTRUCTIONS) while (section::name == section::NAME_INSTRUCTIONS)
{ {
checkInput(); checkInput();
update(); update();
@@ -384,12 +383,12 @@ void Instructions::run()
} }
// Termina // Termina
void Instructions::quit(int code) void Instructions::quit(section::options_e code)
{ {
if (screen->notificationsAreActive()) if (screen->notificationsAreActive())
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
section->options = code; section::options = code;
} }
else else
{ {

View File

@@ -12,6 +12,7 @@
#include "lang.h" #include "lang.h"
#include "tiledbg.h" #include "tiledbg.h"
#include "fade.h" #include "fade.h"
#include "section.h"
/* /*
Esta clase gestiona un estado del programa. Se encarga de poner en pantalla Esta clase gestiona un estado del programa. Se encarga de poner en pantalla
@@ -44,7 +45,6 @@ private:
Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo
Fade *fade; // Objeto para renderizar fades Fade *fade; // Objeto para renderizar fades
JA_Music_t *music; // Musica de fondo JA_Music_t *music; // Musica de fondo
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables // Variables
int counter; // Contador int counter; // Contador
@@ -83,11 +83,11 @@ private:
void reloadTextures(); void reloadTextures();
// Termina // Termina
void quit(int code); void quit(section::options_e code);
public: public:
// Constructor // Constructor
Instructions(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music); Instructions(Screen *screen, Asset *asset, Input *input, JA_Music_t *music);
// Destructor // Destructor
~Instructions(); ~Instructions();

View File

@@ -3,13 +3,12 @@
#include "options.h" #include "options.h"
// Constructor // Constructor
Intro::Intro(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music) Intro::Intro(Screen *screen, Asset *asset, Input *input, JA_Music_t *music)
{ {
// Copia los punteros // Copia los punteros
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->input = input; this->input = input;
this->section = section;
this->music = music; this->music = music;
SDL_Renderer *renderer = screen->getRenderer(); SDL_Renderer *renderer = screen->getRenderer();
@@ -19,8 +18,8 @@ Intro::Intro(Screen *screen, Asset *asset, Input *input, section_t *section, JA_
text = new Text(asset->get("nokia.png"), asset->get("nokia.txt"), renderer); text = new Text(asset->get("nokia.png"), asset->get("nokia.txt"), renderer);
// Inicializa variables // Inicializa variables
section->name = SECTION_PROG_INTRO; section::name = section::NAME_INTRO;
section->options = 0; section::options = section::OPTIONS_NULL;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
scene = 1; scene = 1;
@@ -175,7 +174,7 @@ void Intro::checkEvents()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
break; break;
} }
@@ -196,7 +195,7 @@ void Intro::checkInput()
// Comprueba si se sale con el teclado // Comprueba si se sale con el teclado
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
quit(SECTION_OPTIONS_QUIT_NORMAL); quit(section::OPTIONS_QUIT_NORMAL);
return; return;
} }
@@ -204,8 +203,8 @@ void Intro::checkInput()
if (input->checkAnyButtonPressed()) if (input->checkAnyButtonPressed())
{ {
JA_StopMusic(); JA_StopMusic();
section->name = SECTION_PROG_TITLE; section::name = section::NAME_TITLE;
section->options = SECTION_OPTIONS_TITLE_1; section::options = section::OPTIONS_TITLE_1;
return; return;
} }
@@ -214,14 +213,14 @@ void Intro::checkInput()
// Comprueba si se sale con el mando // Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
quit(SECTION_OPTIONS_QUIT_SHUTDOWN); quit(section::OPTIONS_QUIT_SHUTDOWN);
return; return;
} }
// Comprueba si se va a resetear el juego // Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
section->name = SECTION_PROG_INIT; section::name = section::NAME_INIT;
screen->showNotification("Reset"); screen->showNotification("Reset");
return; return;
} }
@@ -386,8 +385,8 @@ void Intro::updateScenes()
bitmaps[5]->setEnabled(false); bitmaps[5]->setEnabled(false);
texts[8]->setEnabled(false); texts[8]->setEnabled(false);
JA_StopMusic(); JA_StopMusic();
section->name = SECTION_PROG_TITLE; section::name = section::NAME_TITLE;
section->options = SECTION_OPTIONS_TITLE_1; section::options = section::OPTIONS_TITLE_1;
} }
break; break;
@@ -453,7 +452,7 @@ void Intro::run()
{ {
JA_PlayMusic(music, 0); JA_PlayMusic(music, 0);
while (section->name == SECTION_PROG_INTRO) while (section::name == section::NAME_INTRO)
{ {
checkInput(); checkInput();
update(); update();
@@ -463,12 +462,12 @@ void Intro::run()
} }
// Termina // Termina
void Intro::quit(int code) void Intro::quit(section::options_e code)
{ {
if (screen->notificationsAreActive()) if (screen->notificationsAreActive())
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
section->options = code; section::options = code;
} }
else else
{ {

View File

@@ -11,6 +11,7 @@
#include "const.h" #include "const.h"
#include "lang.h" #include "lang.h"
#include <vector> #include <vector>
#include "section.h"
/* /*
Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia
@@ -30,7 +31,6 @@ private:
std::vector<SmartSprite *> bitmaps; // Vector con los sprites inteligentes para los dibujos de la intro std::vector<SmartSprite *> bitmaps; // Vector con los sprites inteligentes para los dibujos de la intro
std::vector<Writer *> texts; // Textos de la intro std::vector<Writer *> texts; // Textos de la intro
Text *text; // Textos de la intro Text *text; // Textos de la intro
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables // Variables
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
@@ -57,11 +57,11 @@ private:
void reloadTextures(); void reloadTextures();
// Termina // Termina
void quit(int code); void quit(section::options_e code);
public: public:
// Constructor // Constructor
Intro(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music); Intro(Screen *screen, Asset *asset, Input *input, JA_Music_t *music);
// Destructor // Destructor
~Intro(); ~Intro();

View File

@@ -4,13 +4,12 @@
#include <iostream> #include <iostream>
// Constructor // Constructor
Logo::Logo(Screen *screen, Asset *asset, Input *input, section_t *section) Logo::Logo(Screen *screen, Asset *asset, Input *input)
{ {
// Copia la dirección de los objetos // Copia la dirección de los objetos
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->input = input; this->input = input;
this->section = section;
SDL_Renderer *renderer = screen->getRenderer(); SDL_Renderer *renderer = screen->getRenderer();
// Reserva memoria para los punteros // Reserva memoria para los punteros
@@ -21,7 +20,7 @@ Logo::Logo(Screen *screen, Asset *asset, Input *input, section_t *section)
// Inicializa variables // Inicializa variables
counter = 0; counter = 0;
section->name = SECTION_PROG_LOGO; section::name = section::NAME_LOGO;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
showSinceSprite_cm = 70; showSinceSprite_cm = 70;
@@ -86,7 +85,7 @@ void Logo::checkEvents()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
break; break;
} }
@@ -107,14 +106,14 @@ void Logo::checkInput()
// Comprueba si se sale con el teclado // Comprueba si se sale con el teclado
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
quit(SECTION_OPTIONS_QUIT_NORMAL); quit(section::OPTIONS_QUIT_NORMAL);
return; return;
} }
// Comprueba si se va a resetear el juego // Comprueba si se va a resetear el juego
if (input->checkInput(input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
section->name = SECTION_PROG_INIT; section::name = section::NAME_INIT;
screen->showNotification("Reset"); screen->showNotification("Reset");
return; return;
} }
@@ -123,8 +122,8 @@ void Logo::checkInput()
if (input->checkAnyButtonPressed()) if (input->checkAnyButtonPressed())
{ {
JA_StopMusic(); JA_StopMusic();
section->name = SECTION_PROG_TITLE; section::name = section::NAME_TITLE;
section->options = SECTION_OPTIONS_TITLE_1; section::options = section::OPTIONS_TITLE_1;
return; return;
} }
@@ -133,14 +132,14 @@ void Logo::checkInput()
// Comprueba si se sale con el mando // Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
quit(SECTION_OPTIONS_QUIT_SHUTDOWN); quit(section::OPTIONS_QUIT_SHUTDOWN);
return; return;
} }
// Comprueba si se va a resetear el juego // Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
section->name = SECTION_PROG_INIT; section::name = section::NAME_INIT;
screen->showNotification("Reset"); screen->showNotification("Reset");
return; return;
} }
@@ -305,7 +304,7 @@ void Logo::update()
// Comprueba si ha terminado el logo // Comprueba si ha terminado el logo
if (counter == endLogo_cm + postLogoDuration) if (counter == endLogo_cm + postLogoDuration)
{ {
section->name = SECTION_PROG_INTRO; section::name = section::NAME_INTRO;
} }
// Comprueba si se ha de mostrar el sprite // Comprueba si se ha de mostrar el sprite
@@ -342,7 +341,7 @@ void Logo::run()
// Detiene la música // Detiene la música
JA_StopMusic(); JA_StopMusic();
while (section->name == SECTION_PROG_LOGO) while (section::name == section::NAME_LOGO)
{ {
checkInput(); checkInput();
update(); update();
@@ -352,12 +351,12 @@ void Logo::run()
} }
// Termina // Termina
void Logo::quit(int code) void Logo::quit(section::options_e code)
{ {
if (screen->notificationsAreActive()) if (screen->notificationsAreActive())
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
section->options = code; section::options = code;
} }
else else
{ {

View File

@@ -1,15 +1,16 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <vector>
#include "asset.h" #include "asset.h"
#include "const.h"
#include "input.h" #include "input.h"
#include "jail_audio.h" #include "jail_audio.h"
#include "lang.h"
#include "screen.h" #include "screen.h"
#include "section.h"
#include "sprite.h" #include "sprite.h"
#include "utils.h" #include "utils.h"
#include "const.h"
#include "lang.h"
#include <vector>
/* /*
Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el
@@ -32,7 +33,6 @@ private:
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
std::vector<Sprite *> jailSprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES std::vector<Sprite *> jailSprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
Sprite *sinceSprite; // Sprite para manejar la sinceTexture Sprite *sinceSprite; // Sprite para manejar la sinceTexture
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables // Variables
std::vector<color_t> color; // Vector con los colores para el fade std::vector<color_t> color; // Vector con los colores para el fade
@@ -68,11 +68,11 @@ private:
void reloadTextures(); void reloadTextures();
// Termina // Termina
void quit(int code); void quit(section::options_e code);
public: public:
// Constructor // Constructor
Logo(Screen *screen, Asset *asset, Input *input, section_t *section); Logo(Screen *screen, Asset *asset, Input *input);
// Destructor // Destructor
~Logo(); ~Logo();

7
source/section.cpp Normal file
View File

@@ -0,0 +1,7 @@
#include "section.h"
namespace section
{
name_e name;
options_e options;
}

35
source/section.h Normal file
View File

@@ -0,0 +1,35 @@
#pragma once
#include <SDL2/SDL.h>
namespace section
{
// Secciones del programa
enum name_e
{
NAME_INIT = 0,
NAME_LOGO = 1,
NAME_INTRO = 2,
NAME_TITLE = 3,
NAME_GAME = 4,
NAME_HI_SCORE_TABLE = 5,
NAME_GAME_DEMO = 6,
NAME_INSTRUCTIONS = 7,
NAME_QUIT = 8,
};
// Opciones para la sección
enum options_e
{
OPTIONS_GAME_PLAY_1P = 0,
OPTIONS_GAME_PLAY_2P = 1,
OPTIONS_TITLE_1 = 2,
OPTIONS_TITLE_2 = 3,
OPTIONS_QUIT_NORMAL = 4,
OPTIONS_QUIT_SHUTDOWN = 5,
OPTIONS_NULL = 6,
};
extern name_e name;
extern options_e options;
}

View File

@@ -3,13 +3,12 @@
#include "options.h" #include "options.h"
// Constructor // Constructor
Title::Title(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music) Title::Title(Screen *screen, Asset *asset, Input *input, JA_Music_t *music)
{ {
// Copia las direcciones de los punteros y objetos // Copia las direcciones de los punteros y objetos
this->screen = screen; this->screen = screen;
this->input = input; this->input = input;
this->asset = asset; this->asset = asset;
this->section = section;
this->music = music; this->music = music;
SDL_Renderer *renderer = screen->getRenderer(); SDL_Renderer *renderer = screen->getRenderer();
@@ -30,7 +29,7 @@ Title::Title(Screen *screen, Asset *asset, Input *input, section_t *section, JA_
gameLogo = new GameLogo(renderer, screen, asset, param.game.gameArea.centerX, param.title.titleCCPosition); gameLogo = new GameLogo(renderer, screen, asset, param.game.gameArea.centerX, param.title.titleCCPosition);
gameLogo->enable(); gameLogo->enable();
defineButtons = new DefineButtons(input, text2, section); defineButtons = new DefineButtons(input, text2);
// Inicializa los valores // Inicializa los valores
init(); init();
@@ -58,9 +57,9 @@ Title::~Title()
void Title::init() void Title::init()
{ {
// Inicializa variables // Inicializa variables
section->options = SECTION_OPTIONS_TITLE_1; section::options = section::OPTIONS_TITLE_1;
counter = 0; counter = 0;
nextSection.name = SECTION_PROG_GAME; nextSection.name = section::NAME_GAME;
postFade = 0; postFade = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -92,28 +91,28 @@ void Title::update()
{ {
if (postFade == -1) if (postFade == -1)
{ {
section->name = SECTION_PROG_GAME_DEMO; section::name = section::NAME_GAME_DEMO;
} }
else else
{ {
section->name = SECTION_PROG_GAME; section::name = section::NAME_GAME;
section->options = postFade; section::options = postFade == 1 ? section::OPTIONS_GAME_PLAY_1P : section::OPTIONS_GAME_PLAY_2P;
JA_StopMusic(); JA_StopMusic();
} }
} }
// Sección 1 - Titulo animandose // Sección 1 - Titulo animandose
if (section->options == SECTION_OPTIONS_TITLE_1) if (section::options == section::OPTIONS_TITLE_1)
{ {
gameLogo->update(); gameLogo->update();
if (gameLogo->hasFinished()) if (gameLogo->hasFinished())
{ {
section->options = SECTION_OPTIONS_TITLE_2; section::options = section::OPTIONS_TITLE_2;
} }
} }
// Sección 2 - La pantalla con el titulo, el fondo animado y la música // Sección 2 - La pantalla con el titulo, el fondo animado y la música
else if (section->options == SECTION_OPTIONS_TITLE_2) else if (section::options == section::OPTIONS_TITLE_2)
{ {
// El contador solo sube si no estamos definiendo botones // El contador solo sube si no estamos definiendo botones
if (!defineButtons->isEnabled()) if (!defineButtons->isEnabled())
@@ -161,7 +160,7 @@ void Title::render()
// Dibuja el logo con el título del juego // Dibuja el logo con el título del juego
gameLogo->render(); gameLogo->render();
if (section->options == SECTION_OPTIONS_TITLE_2) if (section::options == section::OPTIONS_TITLE_2)
{ {
const color_t shadow = {0x14, 0x87, 0xc4}; const color_t shadow = {0x14, 0x87, 0xc4};
// 'PULSA 1P o 2P PARA JUGAR' // 'PULSA 1P o 2P PARA JUGAR'
@@ -202,7 +201,7 @@ void Title::checkEvents()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
break; break;
} }
@@ -251,14 +250,14 @@ void Title::checkInput()
// Comprueba si se sale con el teclado // Comprueba si se sale con el teclado
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
quit(SECTION_OPTIONS_QUIT_NORMAL); quit(section::OPTIONS_QUIT_NORMAL);
return; return;
} }
// Comprueba el teclado para empezar a jugar // Comprueba el teclado para empezar a jugar
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP) if (section::options == section::OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
{ {
fade->activate(); fade->activate();
postFade = options.controller[0].playerId; postFade = options.controller[0].playerId;
@@ -275,14 +274,14 @@ void Title::checkInput()
// Comprueba si se sale con el mando // Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
quit(SECTION_OPTIONS_QUIT_SHUTDOWN); quit(section::OPTIONS_QUIT_SHUTDOWN);
return; return;
} }
// Comprueba si se va a resetear el juego // Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
section->name = SECTION_PROG_LOGO; section::name = section::NAME_LOGO;
screen->showNotification("Reset"); screen->showNotification("Reset");
return; return;
} }
@@ -314,7 +313,7 @@ void Title::checkInput()
// Comprueba el botón de START de los mandos // Comprueba el botón de START de los mandos
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP) if (section::options == section::OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
{ {
fade->activate(); fade->activate();
postFade = options.controller[i].playerId; postFade = options.controller[i].playerId;
@@ -332,7 +331,7 @@ void Title::checkInput()
// Bucle para el titulo del juego // Bucle para el titulo del juego
void Title::run() void Title::run()
{ {
while (section->name == SECTION_PROG_TITLE) while (section::name == section::NAME_TITLE)
{ {
checkInput(); checkInput();
update(); update();
@@ -398,12 +397,12 @@ void Title::swapControllers()
} }
// Termina // Termina
void Title::quit(int code) void Title::quit(section::options_e code)
{ {
if (screen->notificationsAreActive()) if (screen->notificationsAreActive())
{ {
section->name = SECTION_PROG_QUIT; section::name = section::NAME_QUIT;
section->options = code; section::options = code;
} }
else else
{ {

View File

@@ -20,6 +20,7 @@
#include "tiledbg.h" #include "tiledbg.h"
#include "game_logo.h" #include "game_logo.h"
#include "define_buttons.h" #include "define_buttons.h"
#include "section.h"
// Textos // Textos
#define TEXT_COPYRIGHT "@2020,2024 JailDesigner" #define TEXT_COPYRIGHT "@2020,2024 JailDesigner"
@@ -51,7 +52,6 @@ private:
Asset *asset; // Objeto que gestiona todos los ficheros de recursos Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Objeto para leer las entradas de teclado o mando Input *input; // Objeto para leer las entradas de teclado o mando
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
section_t *section; // Indicador para el bucle del titulo
Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo
GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego
DefineButtons *defineButtons; // Objeto para definir los botones del joystic DefineButtons *defineButtons; // Objeto para definir los botones del joystic
@@ -98,11 +98,11 @@ private:
void swapControllers(); void swapControllers();
// Termina // Termina
void quit(int code); void quit(section::options_e code);
public: public:
// Constructor // Constructor
Title(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music); Title(Screen *screen, Asset *asset, Input *input, JA_Music_t *music);
// Destructor // Destructor
~Title(); ~Title();