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;
if (noData || incompleteData)
{
// Pone todos los logros en incompleto
init();
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;
// Secciones del programa
#define SECTION_PROG_LOGO 0
#define SECTION_PROG_INTRO 1
#define SECTION_PROG_TITLE 2
#define SECTION_PROG_CREDITS 3
#define SECTION_PROG_GAME 4
#define SECTION_PROG_DEMO 5
#define SECTION_PROG_GAME_OVER 6
#define SECTION_PROG_ENDING 7
#define SECTION_PROG_ENDING2 8
#define SECTION_PROG_QUIT 9
#define SECTION_LOGO 0
#define SECTION_LOADING_SCREEN 1
#define SECTION_TITLE 2
#define SECTION_CREDITS 3
#define SECTION_GAME 4
#define SECTION_DEMO 5
#define SECTION_GAME_OVER 6
#define SECTION_ENDING 7
#define SECTION_ENDING2 8
#define SECTION_QUIT 9
// Subsecciones
#define SUBSECTION_LOGO_TO_INTRO 0

View File

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

View File

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

View File

@@ -72,7 +72,7 @@ void EnterID::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
loopRunning = false;
break;
}
@@ -124,7 +124,7 @@ void EnterID::checkEvents()
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
loopRunning = false;
break;
}

View File

@@ -1,4 +1,4 @@
#include "credits.h"
#include "gamestate_credits.h"
#include <iostream>
// Constructor
@@ -22,7 +22,7 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
counter = 0;
counterEnabled = true;
subCounter = 0;
section->name = SECTION_PROG_CREDITS;
section->name = SECTION_CREDITS;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
@@ -76,7 +76,7 @@ void Credits::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
break;
}
}
@@ -88,7 +88,7 @@ void Credits::checkInput()
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))
@@ -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))
{
section->name = SECTION_PROG_TITLE;
section->name = SECTION_TITLE;
section->subsection = 0;
}
}
@@ -283,7 +283,7 @@ void Credits::updateCounter()
// Comprueba si ha terminado la sección
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
void Credits::run()
{
while (section->name == SECTION_PROG_CREDITS)
while (section->name == SECTION_CREDITS)
{
update();
checkEvents();

View File

@@ -1,4 +1,4 @@
#include "demo.h"
#include "gamestate_demo.h"
// Constructor
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;
setScoreBoardColor();
section->name = SECTION_PROG_DEMO;
section->name = SECTION_DEMO;
section->subsection = 0;
}
@@ -69,7 +69,7 @@ void Demo::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black"));
break;
}
@@ -82,7 +82,7 @@ void Demo::checkInput()
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))
@@ -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))
{
section->name = SECTION_PROG_TITLE;
section->name = SECTION_TITLE;
section->subsection = 0;
}
}
@@ -124,7 +124,7 @@ void Demo::checkInput()
// Bucle para el juego
void Demo::run()
{
while (section->name == SECTION_PROG_DEMO)
while (section->name == SECTION_DEMO)
{
update();
checkEvents();
@@ -251,7 +251,7 @@ void Demo::checkRoomChange()
roomIndex++;
if (roomIndex == (int)rooms.size())
{
section->name = SECTION_PROG_LOGO;
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_TITLE;
}
else

View File

@@ -1,4 +1,4 @@
#include "ending.h"
#include "gamestate_ending.h"
// Constructor
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;
preCounter = 0;
coverCounter = 0;
section->name = SECTION_PROG_ENDING;
section->name = SECTION_ENDING;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
@@ -152,7 +152,7 @@ void Ending::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
break;
}
}
@@ -164,7 +164,7 @@ void Ending::checkInput()
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_PROG_LOGO;
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
}
@@ -476,7 +476,7 @@ void Ending::run()
{
JA_PlayMusic(music);
while (section->name == SECTION_PROG_ENDING)
while (section->name == SECTION_ENDING)
{
update();
checkEvents();
@@ -560,7 +560,7 @@ void Ending::checkChangeScene()
if (scene == 5)
{
// Termina el bucle
section->name = SECTION_PROG_ENDING2;
section->name = SECTION_ENDING2;
// Mantiene los valores anteriores
scene = 4;

View File

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

View File

@@ -1,4 +1,4 @@
#include "game.h"
#include "gamestate_game.h"
#include <iostream>
// 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;
cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados
section->name = SECTION_PROG_GAME;
section->name = SECTION_GAME;
section->subsection = 0;
}
@@ -119,7 +119,7 @@ void Game::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black"));
break;
}
@@ -189,7 +189,7 @@ void Game::checkInput()
{
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))
@@ -242,7 +242,7 @@ void Game::run()
JA_PauseMusic();
}
while (section->name == SECTION_PROG_GAME)
while (section->name == SECTION_GAME)
{
update();
checkEvents();
@@ -453,7 +453,7 @@ void Game::checkGameOver()
{
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
checkEndGameCheevos();
section->name = SECTION_PROG_ENDING;
section->name = SECTION_ENDING;
return true;
}

View File

@@ -1,4 +1,4 @@
#include "game_over.h"
#include "gamestate_game_over.h"
// Constructor
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
preCounter = 0;
counter = 0;
section->name = SECTION_PROG_GAME_OVER;
section->name = SECTION_GAME_OVER;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
@@ -123,7 +123,7 @@ void GameOver::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
section->subsection = 0;
break;
}
@@ -136,7 +136,7 @@ void GameOver::checkInput()
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))
@@ -168,7 +168,7 @@ void GameOver::checkInput()
// Bucle principal
void GameOver::run()
{
while (section->name == SECTION_PROG_GAME_OVER)
while (section->name == SECTION_GAME_OVER)
{
update();
checkEvents();
@@ -227,7 +227,7 @@ void GameOver::updateCounters()
// Comprueba si ha terminado la sección
else if (counter == endSection)
{
section->name = SECTION_PROG_LOGO;
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_TITLE;
}
}

View File

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

View File

@@ -14,10 +14,10 @@
#include <string>
#include "jail_engine/text.h"
#ifndef INTRO_H
#define INTRO_H
#ifndef LOADING_SCREEN_H
#define LOADING_SCREEN_H
class Intro
class LoadingScreen
{
private:
// Objetos y punteros
@@ -79,10 +79,10 @@ private:
public:
// 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
~Intro();
~LoadingScreen();
// Bucle principal
void run();

View File

@@ -1,4 +1,4 @@
#include "logo.h"
#include "gamestate_logo.h"
#include <iostream>
// Constructor
@@ -39,7 +39,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
// Inicializa variables
counter = 0;
section->name = SECTION_PROG_LOGO;
section->name = SECTION_LOGO;
ticks = 0;
ticksSpeed = 15;
initFade = 300;
@@ -78,7 +78,7 @@ void Logo::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
break;
}
}
@@ -89,7 +89,7 @@ void Logo::checkInput()
{
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))
@@ -303,7 +303,7 @@ void Logo::run()
// Detiene la música
JA_StopMusic();
while (section->name == SECTION_PROG_LOGO)
while (section->name == SECTION_LOGO)
{
update();
checkEvents();
@@ -322,11 +322,11 @@ void Logo::endSection()
{
if (section->subsection == SUBSECTION_LOGO_TO_TITLE)
{
section->name = SECTION_PROG_TITLE;
section->name = SECTION_TITLE;
}
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
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
counter = 0;
section->name = SECTION_PROG_TITLE;
section->name = SECTION_TITLE;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
@@ -97,7 +97,7 @@ void Title::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
break;
}
@@ -109,7 +109,7 @@ void Title::checkEvents()
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_1:
section->name = SECTION_PROG_GAME;
section->name = SECTION_GAME;
section->subsection = 0;
break;
@@ -157,7 +157,7 @@ void Title::checkInput()
}
else
{
section->name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
}
}
@@ -194,7 +194,7 @@ void Title::checkInput()
{
if (!showCheevos)
{
// section->name = SECTION_PROG_GAME;
// section->name = SECTION_GAME;
// section->subsection = 0;
}
}
@@ -278,7 +278,7 @@ void Title::update()
{
if (!showCheevos)
{
section->name = SECTION_PROG_CREDITS;
section->name = SECTION_CREDITS;
section->subsection = 0;
}
}
@@ -310,7 +310,7 @@ void Title::render()
// Bucle para el logo del juego
void Title::run()
{
while (section->name == SECTION_PROG_TITLE)
while (section->name == SECTION_TITLE)
{
update();
checkEvents();