Se me ha ocurrido y lo he hecho antes que nadie: poner prefijo a los .cpp i .h que definen cada uno de los estados del juego

This commit is contained in:
2023-10-10 17:46:02 +02:00
parent f602b5ff7a
commit 6de3050255
23 changed files with 148 additions and 147 deletions

View File

@@ -305,6 +305,7 @@ void Cheevos::loadFromServer()
const bool incompleteData = cheevosData.length() != cheevos.size() ? true : false; const bool incompleteData = cheevosData.length() != cheevos.size() ? true : false;
if (noData || incompleteData) if (noData || incompleteData)
{ {
// Pone todos los logros en incompleto
init(); init();
return; return;
} }

View File

@@ -48,16 +48,16 @@ const int GAMECANVAS_FIRST_QUARTER_Y = GAMECANVAS_HEIGHT / 4;
const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3; const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
// Secciones del programa // Secciones del programa
#define SECTION_PROG_LOGO 0 #define SECTION_LOGO 0
#define SECTION_PROG_INTRO 1 #define SECTION_LOADING_SCREEN 1
#define SECTION_PROG_TITLE 2 #define SECTION_TITLE 2
#define SECTION_PROG_CREDITS 3 #define SECTION_CREDITS 3
#define SECTION_PROG_GAME 4 #define SECTION_GAME 4
#define SECTION_PROG_DEMO 5 #define SECTION_DEMO 5
#define SECTION_PROG_GAME_OVER 6 #define SECTION_GAME_OVER 6
#define SECTION_PROG_ENDING 7 #define SECTION_ENDING 7
#define SECTION_PROG_ENDING2 8 #define SECTION_ENDING2 8
#define SECTION_PROG_QUIT 9 #define SECTION_QUIT 9
// Subsecciones // Subsecciones
#define SUBSECTION_LOGO_TO_INTRO 0 #define SUBSECTION_LOGO_TO_INTRO 0

View File

@@ -15,11 +15,11 @@
Director::Director(int argc, char *argv[]) Director::Director(int argc, char *argv[])
{ {
section = new section_t(); section = new section_t();
section->name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO; section->subsection = SUBSECTION_LOGO_TO_INTRO;
#ifdef DEBUG #ifdef DEBUG
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
#endif #endif
// Crea e inicializa las opciones del programa // Crea e inicializa las opciones del programa
@@ -477,7 +477,7 @@ void Director::loadResources(section_t *section)
std::cout << "** LOAD RESOURCES" << std::endl; std::cout << "** LOAD RESOURCES" << std::endl;
} }
if (section->name == SECTION_PROG_LOGO) if (section->name == SECTION_LOGO)
{ {
std::vector<std::string> textureList; std::vector<std::string> textureList;
textureList.push_back("jailgames.png"); textureList.push_back("jailgames.png");
@@ -486,7 +486,7 @@ void Director::loadResources(section_t *section)
resource->loadTextures(textureList); resource->loadTextures(textureList);
} }
else if (section->name == SECTION_PROG_INTRO) else if (section->name == SECTION_LOADING_SCREEN)
{ {
std::vector<std::string> textureList; std::vector<std::string> textureList;
textureList.push_back("loading_screen_bn.png"); textureList.push_back("loading_screen_bn.png");
@@ -497,7 +497,7 @@ void Director::loadResources(section_t *section)
resource->loadTextures(textureList); resource->loadTextures(textureList);
} }
else if (section->name == SECTION_PROG_TITLE) else if (section->name == SECTION_TITLE)
{ {
std::vector<std::string> textureList; std::vector<std::string> textureList;
textureList.push_back("loading_screen_color.png"); textureList.push_back("loading_screen_color.png");
@@ -516,7 +516,7 @@ void Director::loadResources(section_t *section)
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section->name == SECTION_PROG_CREDITS) else if (section->name == SECTION_CREDITS)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -538,7 +538,7 @@ void Director::loadResources(section_t *section)
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section->name == SECTION_PROG_ENDING) else if (section->name == SECTION_ENDING)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -563,7 +563,7 @@ void Director::loadResources(section_t *section)
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section->name == SECTION_PROG_ENDING2) else if (section->name == SECTION_ENDING2)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -701,7 +701,7 @@ void Director::loadResources(section_t *section)
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section->name == SECTION_PROG_GAME_OVER) else if (section->name == SECTION_GAME_OVER)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -725,7 +725,7 @@ void Director::loadResources(section_t *section)
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section->name == SECTION_PROG_GAME || section->name == SECTION_PROG_DEMO) else if (section->name == SECTION_GAME || section->name == SECTION_DEMO)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -1737,17 +1737,17 @@ void Director::runLogo()
resource->free(); resource->free();
} }
// Ejecuta la seccion de juego de la introducción // Ejecuta la seccion de juego de la pantalla de carga
void Director::runIntro() void Director::runLoadingScreen()
{ {
if (options->console) if (options->console)
{ {
std::cout << "\n* SECTION: INTRO" << std::endl; std::cout << "\n* SECTION: INTRO" << std::endl;
} }
loadResources(section); loadResources(section);
intro = new Intro(renderer, screen, resource, asset, input, options, section); loadingScreen = new LoadingScreen(renderer, screen, resource, asset, input, options, section);
intro->run(); loadingScreen->run();
delete intro; delete loadingScreen;
resource->free(); resource->free();
} }
@@ -1857,43 +1857,43 @@ void Director::runGame()
void Director::run() void Director::run()
{ {
// Bucle principal // Bucle principal
while (section->name != SECTION_PROG_QUIT) while (section->name != SECTION_QUIT)
{ {
switch (section->name) switch (section->name)
{ {
case SECTION_PROG_LOGO: case SECTION_LOGO:
runLogo(); runLogo();
break; break;
case SECTION_PROG_INTRO: case SECTION_LOADING_SCREEN:
runIntro(); runLoadingScreen();
break; break;
case SECTION_PROG_TITLE: case SECTION_TITLE:
runTitle(); runTitle();
break; break;
case SECTION_PROG_CREDITS: case SECTION_CREDITS:
runCredits(); runCredits();
break; break;
case SECTION_PROG_DEMO: case SECTION_DEMO:
runDemo(); runDemo();
break; break;
case SECTION_PROG_GAME: case SECTION_GAME:
runGame(); runGame();
break; break;
case SECTION_PROG_GAME_OVER: case SECTION_GAME_OVER:
runGameOver(); runGameOver();
break; break;
case SECTION_PROG_ENDING: case SECTION_ENDING:
runEnding(); runEnding();
break; break;
case SECTION_PROG_ENDING2: case SECTION_ENDING2:
runEnding2(); runEnding2();
break; break;
} }

View File

@@ -10,17 +10,17 @@
#include "jail_engine/text.h" #include "jail_engine/text.h"
#include "jail_engine/utils.h" #include "jail_engine/utils.h"
#include "const.h" #include "const.h"
#include "credits.h" #include "gamestate_credits.h"
#include "demo.h" #include "gamestate_demo.h"
#include "ending.h" #include "gamestate_ending.h"
#include "ending2.h" #include "gamestate_ending2.h"
#include "enter_id.h" #include "enter_id.h"
#include "game_over.h" #include "gamestate_game_over.h"
#include "game.h" #include "gamestate_game.h"
#include "intro.h" #include "gamestate_loading_screen.h"
#include "logo.h" #include "gamestate_logo.h"
#include "online.h" #include "online.h"
#include "title.h" #include "gamestate_title.h"
#ifndef DIRECTOR_H #ifndef DIRECTOR_H
#define DIRECTOR_H #define DIRECTOR_H
@@ -29,25 +29,25 @@ class Director
{ {
private: private:
// Objetos y punteros // Objetos y punteros
SDL_Window *window; // La ventana donde dibujamos SDL_Window *window; // La ventana donde dibujamos
SDL_Renderer *renderer; // El renderizador de la ventana SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto que gestiona todos los ficheros de recursos Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Objeto Input para gestionar las entradas Input *input; // Objeto Input para gestionar las entradas
Game *game; // Objeto para gestionar la sección del juego Game *game; // Objeto para gestionar la sección del juego
Logo *logo; // Objeto para gestionar la sección del logo del programa Logo *logo; // Objeto para gestionar la sección del logo del programa
Title *title; // Objeto para gestionar la pantalla de título Title *title; // Objeto para gestionar la pantalla de título
Intro *intro; // Objeto para gestionar la introducción del juego LoadingScreen *loadingScreen; // Objeto para gestionar la introducción del juego
Credits *credits; // Objeto para gestionar los creditos del juego Credits *credits; // Objeto para gestionar los creditos del juego
Demo *demo; // Objeto para gestionar el modo demo, en el que se ven pantallas del juego Demo *demo; // Objeto para gestionar el modo demo, en el que se ven pantallas del juego
Ending *ending; // Objeto para gestionar el final del juego Ending *ending; // Objeto para gestionar el final del juego
Ending2 *ending2; // Objeto para gestionar el final del juego Ending2 *ending2; // Objeto para gestionar el final del juego
GameOver *gameOver; // Objeto para gestionar el final de la partida GameOver *gameOver; // Objeto para gestionar el final de la partida
Debug *debug; // Objeto para getsionar la información de debug Debug *debug; // Objeto para getsionar la información de debug
Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto
struct options_t *options; // Variable con todas las opciones del programa struct options_t *options; // Variable con todas las opciones del programa
section_t *section; // Sección y subsección actual del programa; section_t *section; // Sección y subsección actual del programa;
// Variables // Variables
JA_Music_t *music; // Musica del titulo JA_Music_t *music; // Musica del titulo
@@ -93,8 +93,8 @@ private:
// Ejecuta la seccion de juego con el logo // Ejecuta la seccion de juego con el logo
void runLogo(); void runLogo();
// Ejecuta la seccion de juego de la introducción // Ejecuta la seccion de juego de la pantalla de carga
void runIntro(); void runLoadingScreen();
// Ejecuta la seccion de juego con el titulo y los menus // Ejecuta la seccion de juego con el titulo y los menus
void runTitle(); void runTitle();

View File

@@ -72,7 +72,7 @@ void EnterID::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_QUIT;
loopRunning = false; loopRunning = false;
break; break;
} }
@@ -124,7 +124,7 @@ void EnterID::checkEvents()
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE) else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
loopRunning = false; loopRunning = false;
break; break;
} }

View File

@@ -1,4 +1,4 @@
#include "credits.h" #include "gamestate_credits.h"
#include <iostream> #include <iostream>
// Constructor // Constructor
@@ -22,7 +22,7 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
counter = 0; counter = 0;
counterEnabled = true; counterEnabled = true;
subCounter = 0; subCounter = 0;
section->name = SECTION_PROG_CREDITS; section->name = SECTION_CREDITS;
section->subsection = 0; section->subsection = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -76,7 +76,7 @@ void Credits::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_QUIT;
break; break;
} }
} }
@@ -88,7 +88,7 @@ void Credits::checkInput()
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
} }
else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
@@ -118,7 +118,7 @@ void Credits::checkInput()
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE)) else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
section->subsection = 0; section->subsection = 0;
} }
} }
@@ -283,7 +283,7 @@ void Credits::updateCounter()
// Comprueba si ha terminado la sección // Comprueba si ha terminado la sección
if (counter > 1200) if (counter > 1200)
{ {
section->name = SECTION_PROG_DEMO; section->name = SECTION_DEMO;
} }
} }
@@ -344,7 +344,7 @@ void Credits::render()
// Bucle para el logo del juego // Bucle para el logo del juego
void Credits::run() void Credits::run()
{ {
while (section->name == SECTION_PROG_CREDITS) while (section->name == SECTION_CREDITS)
{ {
update(); update();
checkEvents(); checkEvents();

View File

@@ -1,4 +1,4 @@
#include "demo.h" #include "gamestate_demo.h"
// Constructor // Constructor
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug) Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug)
@@ -46,7 +46,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
board.music = true; board.music = true;
setScoreBoardColor(); setScoreBoardColor();
section->name = SECTION_PROG_DEMO; section->name = SECTION_DEMO;
section->subsection = 0; section->subsection = 0;
} }
@@ -69,7 +69,7 @@ void Demo::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_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black")); screen->setBorderColor(stringToColor(options->palette, "black"));
break; break;
} }
@@ -82,7 +82,7 @@ void Demo::checkInput()
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
} }
else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
@@ -116,7 +116,7 @@ void Demo::checkInput()
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE)) else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
section->subsection = 0; section->subsection = 0;
} }
} }
@@ -124,7 +124,7 @@ void Demo::checkInput()
// Bucle para el juego // Bucle para el juego
void Demo::run() void Demo::run()
{ {
while (section->name == SECTION_PROG_DEMO) while (section->name == SECTION_DEMO)
{ {
update(); update();
checkEvents(); checkEvents();
@@ -251,7 +251,7 @@ void Demo::checkRoomChange()
roomIndex++; roomIndex++;
if (roomIndex == (int)rooms.size()) if (roomIndex == (int)rooms.size())
{ {
section->name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_TITLE; section->subsection = SUBSECTION_LOGO_TO_TITLE;
} }
else else

View File

@@ -1,4 +1,4 @@
#include "ending.h" #include "gamestate_ending.h"
// Constructor // Constructor
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section) Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
@@ -21,7 +21,7 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
counter = -1; counter = -1;
preCounter = 0; preCounter = 0;
coverCounter = 0; coverCounter = 0;
section->name = SECTION_PROG_ENDING; section->name = SECTION_ENDING;
section->subsection = 0; section->subsection = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -152,7 +152,7 @@ void Ending::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_QUIT;
break; break;
} }
} }
@@ -164,7 +164,7 @@ void Ending::checkInput()
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO; section->subsection = SUBSECTION_LOGO_TO_INTRO;
} }
@@ -476,7 +476,7 @@ void Ending::run()
{ {
JA_PlayMusic(music); JA_PlayMusic(music);
while (section->name == SECTION_PROG_ENDING) while (section->name == SECTION_ENDING)
{ {
update(); update();
checkEvents(); checkEvents();
@@ -560,7 +560,7 @@ void Ending::checkChangeScene()
if (scene == 5) if (scene == 5)
{ {
// Termina el bucle // Termina el bucle
section->name = SECTION_PROG_ENDING2; section->name = SECTION_ENDING2;
// Mantiene los valores anteriores // Mantiene los valores anteriores
scene = 4; scene = 4;

View File

@@ -1,4 +1,4 @@
#include "ending2.h" #include "gamestate_ending2.h"
#include <algorithm> #include <algorithm>
// Constructor // Constructor
@@ -23,7 +23,7 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
preCounter = 0; preCounter = 0;
postCounter = 0; postCounter = 0;
postCounterEnabled = false; postCounterEnabled = false;
section->name = SECTION_PROG_ENDING2; section->name = SECTION_ENDING2;
section->subsection = 0; section->subsection = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -186,7 +186,7 @@ void Ending2::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_QUIT;
break; break;
} }
} }
@@ -198,7 +198,7 @@ void Ending2::checkInput()
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO; section->subsection = SUBSECTION_LOGO_TO_INTRO;
} }
@@ -233,7 +233,7 @@ void Ending2::run()
{ {
JA_PlayMusic(music); JA_PlayMusic(music);
while (section->name == SECTION_PROG_ENDING2) while (section->name == SECTION_ENDING2)
{ {
update(); update();
checkEvents(); checkEvents();
@@ -264,7 +264,7 @@ void Ending2::updateCounters()
if (postCounter > 600) if (postCounter > 600)
{ {
section->name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO; section->subsection = SUBSECTION_LOGO_TO_INTRO;
} }
} }

View File

@@ -1,4 +1,4 @@
#include "game.h" #include "gamestate_game.h"
#include <iostream> #include <iostream>
// Constructor // Constructor
@@ -87,7 +87,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled; const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled;
cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados
section->name = SECTION_PROG_GAME; section->name = SECTION_GAME;
section->subsection = 0; section->subsection = 0;
} }
@@ -119,7 +119,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_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black")); screen->setBorderColor(stringToColor(options->palette, "black"));
break; break;
} }
@@ -189,7 +189,7 @@ void Game::checkInput()
{ {
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
} }
else if (input->checkInput(input_switch_music, REPEAT_FALSE)) else if (input->checkInput(input_switch_music, REPEAT_FALSE))
@@ -242,7 +242,7 @@ void Game::run()
JA_PauseMusic(); JA_PauseMusic();
} }
while (section->name == SECTION_PROG_GAME) while (section->name == SECTION_GAME)
{ {
update(); update();
checkEvents(); checkEvents();
@@ -453,7 +453,7 @@ void Game::checkGameOver()
{ {
if (board.lives < 0 && blackScreenCounter > 17) if (board.lives < 0 && blackScreenCounter > 17)
{ {
section->name = SECTION_PROG_GAME_OVER; section->name = SECTION_GAME_OVER;
} }
} }
@@ -596,7 +596,7 @@ bool Game::checkEndGame()
// Comprueba los logros de completar el juego // Comprueba los logros de completar el juego
checkEndGameCheevos(); checkEndGameCheevos();
section->name = SECTION_PROG_ENDING; section->name = SECTION_ENDING;
return true; return true;
} }

View File

@@ -1,4 +1,4 @@
#include "game_over.h" #include "gamestate_game_over.h"
// Constructor // Constructor
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section) GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
@@ -22,7 +22,7 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A
// Inicializa variables // Inicializa variables
preCounter = 0; preCounter = 0;
counter = 0; counter = 0;
section->name = SECTION_PROG_GAME_OVER; section->name = SECTION_GAME_OVER;
section->subsection = 0; section->subsection = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -123,7 +123,7 @@ void GameOver::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_QUIT;
section->subsection = 0; section->subsection = 0;
break; break;
} }
@@ -136,7 +136,7 @@ void GameOver::checkInput()
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
} }
else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
@@ -168,7 +168,7 @@ void GameOver::checkInput()
// Bucle principal // Bucle principal
void GameOver::run() void GameOver::run()
{ {
while (section->name == SECTION_PROG_GAME_OVER) while (section->name == SECTION_GAME_OVER)
{ {
update(); update();
checkEvents(); checkEvents();
@@ -227,7 +227,7 @@ void GameOver::updateCounters()
// Comprueba si ha terminado la sección // Comprueba si ha terminado la sección
else if (counter == endSection) else if (counter == endSection)
{ {
section->name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_TITLE; section->subsection = SUBSECTION_LOGO_TO_TITLE;
} }
} }

View File

@@ -1,7 +1,7 @@
#include "intro.h" #include "gamestate_loading_screen.h"
// Constructor // Constructor
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section) LoadingScreen::LoadingScreen(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
{ {
// Copia la dirección de los objetos // Copia la dirección de los objetos
this->resource = resource; this->resource = resource;
@@ -33,7 +33,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
// Inicializa variables // Inicializa variables
preCounter = 0; preCounter = 0;
counter = 0; counter = 0;
section->name = SECTION_PROG_INTRO; section->name = SECTION_LOADING_SCREEN;
section->subsection = 0; section->subsection = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -65,7 +65,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
} }
// Destructor // Destructor
Intro::~Intro() LoadingScreen::~LoadingScreen()
{ {
delete sprite1; delete sprite1;
delete sprite2; delete sprite2;
@@ -76,7 +76,7 @@ Intro::~Intro()
} }
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void Intro::checkEvents() void LoadingScreen::checkEvents()
{ {
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler) != 0)
@@ -84,19 +84,19 @@ 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_QUIT;
break; break;
} }
} }
} }
// Comprueba las entradas // Comprueba las entradas
void Intro::checkInput() void LoadingScreen::checkInput()
{ {
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
} }
else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
@@ -126,13 +126,13 @@ void Intro::checkInput()
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE)) else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
section->subsection = 0; section->subsection = 0;
} }
} }
// Gestiona el contador de carga // Gestiona el contador de carga
void Intro::updateLoad() void LoadingScreen::updateLoad()
{ {
// Primera parte de la carga, la parte en blanco y negro // Primera parte de la carga, la parte en blanco y negro
if (loadingFirstPart) if (loadingFirstPart)
@@ -172,7 +172,7 @@ void Intro::updateLoad()
// Comprueba si ha terminado la intro // Comprueba si ha terminado la intro
if (loadCounter >= 768) if (loadCounter >= 768)
{ {
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
section->subsection = 0; section->subsection = 0;
JA_StopMusic(); JA_StopMusic();
} }
@@ -180,7 +180,7 @@ void Intro::updateLoad()
} }
// Gestiona el contador interno // Gestiona el contador interno
void Intro::updateCounter() void LoadingScreen::updateCounter()
{ {
(preCounter >= 50) ? counter++ : preCounter++; (preCounter >= 50) ? counter++ : preCounter++;
@@ -191,13 +191,13 @@ void Intro::updateCounter()
} }
// Dibuja la pantalla de carga // Dibuja la pantalla de carga
void Intro::renderLoad() void LoadingScreen::renderLoad()
{ {
loadingFirstPart ? sprite1->render() : sprite2->render(); loadingFirstPart ? sprite1->render() : sprite2->render();
} }
// Dibuja el efecto de carga en el borde // Dibuja el efecto de carga en el borde
void Intro::renderBorder() void LoadingScreen::renderBorder()
{ {
// Pinta el borde de colro azul // Pinta el borde de colro azul
color_t color = stringToColor(options->palette, "blue"); color_t color = stringToColor(options->palette, "blue");
@@ -233,7 +233,7 @@ void Intro::renderBorder()
} }
// Actualiza las variables // Actualiza las variables
void Intro::update() void LoadingScreen::update()
{ {
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
if (SDL_GetTicks() - ticks > ticksSpeed) if (SDL_GetTicks() - ticks > ticksSpeed)
@@ -256,7 +256,7 @@ void Intro::update()
} }
// Dibuja en pantalla // Dibuja en pantalla
void Intro::render() void LoadingScreen::render()
{ {
if (options->borderEnabled) if (options->borderEnabled)
{ {
@@ -278,7 +278,7 @@ void Intro::render()
} }
// Bucle para el logo del juego // Bucle para el logo del juego
void Intro::run() void LoadingScreen::run()
{ {
// Inicia el sonido de carga // Inicia el sonido de carga
JA_SetVolume(64); JA_SetVolume(64);
@@ -289,7 +289,7 @@ void Intro::run()
screen->clean(); screen->clean();
screen->blit(); screen->blit();
while (section->name == SECTION_PROG_INTRO) while (section->name == SECTION_LOADING_SCREEN)
{ {
update(); update();
checkEvents(); checkEvents();
@@ -300,7 +300,7 @@ void Intro::run()
} }
// Cambia la paleta // Cambia la paleta
void Intro::switchPalette() void LoadingScreen::switchPalette()
{ {
if (options->palette == p_zxspectrum) if (options->palette == p_zxspectrum)
{ {
@@ -319,7 +319,7 @@ void Intro::switchPalette()
} }
// Reconstruye la pantalla de carga // Reconstruye la pantalla de carga
void Intro::recreateLoadingScreen() void LoadingScreen::recreateLoadingScreen()
{ {
// Prepara para empezar a dibujar en la textura de juego // Prepara para empezar a dibujar en la textura de juego
screen->start(); screen->start();

View File

@@ -14,10 +14,10 @@
#include <string> #include <string>
#include "jail_engine/text.h" #include "jail_engine/text.h"
#ifndef INTRO_H #ifndef LOADING_SCREEN_H
#define INTRO_H #define LOADING_SCREEN_H
class Intro class LoadingScreen
{ {
private: private:
// Objetos y punteros // Objetos y punteros
@@ -79,10 +79,10 @@ private:
public: public:
// Constructor // Constructor
Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section); LoadingScreen(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
// Destructor // Destructor
~Intro(); ~LoadingScreen();
// Bucle principal // Bucle principal
void run(); void run();

View File

@@ -1,4 +1,4 @@
#include "logo.h" #include "gamestate_logo.h"
#include <iostream> #include <iostream>
// Constructor // Constructor
@@ -39,7 +39,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
// Inicializa variables // Inicializa variables
counter = 0; counter = 0;
section->name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
initFade = 300; initFade = 300;
@@ -78,7 +78,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_QUIT;
break; break;
} }
} }
@@ -89,7 +89,7 @@ void Logo::checkInput()
{ {
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
} }
else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
@@ -303,7 +303,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_LOGO)
{ {
update(); update();
checkEvents(); checkEvents();
@@ -322,11 +322,11 @@ void Logo::endSection()
{ {
if (section->subsection == SUBSECTION_LOGO_TO_TITLE) if (section->subsection == SUBSECTION_LOGO_TO_TITLE)
{ {
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
} }
else if (section->subsection == SUBSECTION_LOGO_TO_INTRO) else if (section->subsection == SUBSECTION_LOGO_TO_INTRO)
{ {
section->name = SECTION_PROG_INTRO; section->name = SECTION_LOADING_SCREEN;
} }
} }

View File

@@ -1,4 +1,4 @@
#include "title.h" #include "gamestate_title.h"
// Constructor // Constructor
Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, Online *online, options_t *options, section_t *section) Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, Online *online, options_t *options, section_t *section)
@@ -41,7 +41,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
// Inicializa variables // Inicializa variables
counter = 0; counter = 0;
section->name = SECTION_PROG_TITLE; section->name = SECTION_TITLE;
section->subsection = 0; section->subsection = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -97,7 +97,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_QUIT;
break; break;
} }
@@ -109,7 +109,7 @@ void Title::checkEvents()
switch (eventHandler->key.keysym.scancode) switch (eventHandler->key.keysym.scancode)
{ {
case SDL_SCANCODE_1: case SDL_SCANCODE_1:
section->name = SECTION_PROG_GAME; section->name = SECTION_GAME;
section->subsection = 0; section->subsection = 0;
break; break;
@@ -157,7 +157,7 @@ void Title::checkInput()
} }
else else
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
} }
} }
@@ -194,7 +194,7 @@ void Title::checkInput()
{ {
if (!showCheevos) if (!showCheevos)
{ {
// section->name = SECTION_PROG_GAME; // section->name = SECTION_GAME;
// section->subsection = 0; // section->subsection = 0;
} }
} }
@@ -278,7 +278,7 @@ void Title::update()
{ {
if (!showCheevos) if (!showCheevos)
{ {
section->name = SECTION_PROG_CREDITS; section->name = SECTION_CREDITS;
section->subsection = 0; section->subsection = 0;
} }
} }
@@ -310,7 +310,7 @@ void Title::render()
// Bucle para el logo del juego // Bucle para el logo del juego
void Title::run() void Title::run()
{ {
while (section->name == SECTION_PROG_TITLE) while (section->name == SECTION_TITLE)
{ {
update(); update();
checkEvents(); checkEvents();