forked from jaildesigner-jailgames/jaildoctors_dilemma
Cambiada la variable section por un puntero
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, 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;
|
||||||
@@ -10,6 +10,7 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -20,8 +21,8 @@ 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_PROG_CREDITS;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
sprite->setRect({194, 174, 8, 8});
|
sprite->setRect({194, 174, 8, 8});
|
||||||
@@ -74,7 +75,7 @@ void Credits::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ void Credits::checkEventHandler()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
case SDL_SCANCODE_B:
|
||||||
@@ -122,8 +123,8 @@ void Credits::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
section.name = SECTION_PROG_TITLE;
|
section->name = SECTION_PROG_TITLE;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +260,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_PROG_DEMO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,15 +319,13 @@ void Credits::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Credits::run()
|
void Credits::run()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_CREDITS)
|
while (section->name == SECTION_PROG_CREDITS)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ private:
|
|||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
||||||
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
bool counterEnabled; // Indica si esta activo el contador
|
bool counterEnabled; // Indica si esta activo el contador
|
||||||
int subCounter; // Contador secundario
|
int subCounter; // Contador secundario
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::vector<captions_t> texts; // Vector con los textos
|
std::vector<captions_t> texts; // Vector con los textos
|
||||||
@@ -69,13 +69,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Credits();
|
~Credits();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug)
|
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
board.iniClock = SDL_GetTicks();
|
board.iniClock = SDL_GetTicks();
|
||||||
@@ -24,6 +24,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
@@ -44,8 +45,8 @@ 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_PROG_DEMO;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Demo::~Demo()
|
Demo::~Demo()
|
||||||
@@ -67,7 +68,7 @@ void Demo::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -78,7 +79,7 @@ void Demo::checkEventHandler()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
case SDL_SCANCODE_B:
|
||||||
@@ -116,8 +117,8 @@ void Demo::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
section.name = SECTION_PROG_TITLE;
|
section->name = SECTION_PROG_TITLE;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,15 +126,13 @@ void Demo::checkEventHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t Demo::run()
|
void Demo::run()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_DEMO)
|
while (section->name == SECTION_PROG_DEMO)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
@@ -255,8 +254,8 @@ void Demo::checkRoomChange()
|
|||||||
roomIndex++;
|
roomIndex++;
|
||||||
if (roomIndex == (int)rooms.size())
|
if (roomIndex == (int)rooms.size())
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ private:
|
|||||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Seccion actual dentro del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
section_t section; // Seccion actual dentro del juego
|
|
||||||
std::string currentRoom; // Fichero de la habitación actual
|
std::string currentRoom; // Fichero de la habitación actual
|
||||||
board_t board; // Estructura con los datos del marcador
|
board_t board; // Estructura con los datos del marcador
|
||||||
int counter; // Contador para el modo demo
|
int counter; // Contador para el modo demo
|
||||||
@@ -75,13 +75,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug);
|
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Demo();
|
~Demo();
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,11 +14,12 @@
|
|||||||
// Constructor
|
// Constructor
|
||||||
Director::Director(int argc, char *argv[])
|
Director::Director(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section = new section_t();
|
||||||
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea e inicializa las opciones del programa
|
// Crea e inicializa las opciones del programa
|
||||||
@@ -65,6 +66,7 @@ Director::~Director()
|
|||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
// Libera la memoria
|
// Libera la memoria
|
||||||
|
delete section;
|
||||||
delete options;
|
delete options;
|
||||||
delete asset;
|
delete asset;
|
||||||
delete input;
|
delete input;
|
||||||
@@ -463,14 +465,14 @@ void Director::createSystemFolder()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
void Director::loadResources(section_t section)
|
void Director::loadResources(section_t *section)
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << "** LOAD RESOURCES" << std::endl;
|
std::cout << "** LOAD RESOURCES" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (section.name == SECTION_PROG_LOGO)
|
if (section->name == SECTION_PROG_LOGO)
|
||||||
{
|
{
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
textureList.push_back("jailgames.png");
|
textureList.push_back("jailgames.png");
|
||||||
@@ -479,7 +481,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_PROG_INTRO)
|
||||||
{
|
{
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
textureList.push_back("loading_screen_bn.png");
|
textureList.push_back("loading_screen_bn.png");
|
||||||
@@ -490,7 +492,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_PROG_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");
|
||||||
@@ -506,7 +508,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_PROG_CREDITS)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -528,7 +530,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_PROG_ENDING)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -553,7 +555,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_PROG_ENDING2)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -691,7 +693,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_PROG_GAME_OVER)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -715,7 +717,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_PROG_GAME || section->name == SECTION_PROG_DEMO)
|
||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
@@ -1686,24 +1688,6 @@ bool Director::setFileList()
|
|||||||
return asset->check();
|
return asset->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 Director::getSubsection()
|
|
||||||
{
|
|
||||||
return section.subsection;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 Director::getSection()
|
|
||||||
{
|
|
||||||
return section.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Director::setSection(section_t section)
|
|
||||||
{
|
|
||||||
this->section = section;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ejecuta la seccion de juego con el logo
|
// Ejecuta la seccion de juego con el logo
|
||||||
void Director::runLogo()
|
void Director::runLogo()
|
||||||
{
|
{
|
||||||
@@ -1712,8 +1696,8 @@ void Director::runLogo()
|
|||||||
std::cout << "\n* SECTION: LOGO" << std::endl;
|
std::cout << "\n* SECTION: LOGO" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
logo = new Logo(renderer, screen, resource, asset, options, section.subsection);
|
logo = new Logo(renderer, screen, resource, asset, options, section);
|
||||||
setSection(logo->run());
|
logo->run();
|
||||||
delete logo;
|
delete logo;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1726,8 +1710,8 @@ void Director::runIntro()
|
|||||||
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, options);
|
intro = new Intro(renderer, screen, resource, asset, options, section);
|
||||||
setSection(intro->run());
|
intro->run();
|
||||||
delete intro;
|
delete intro;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1744,8 +1728,8 @@ void Director::runTitle()
|
|||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
title = new Title(renderer, screen, resource, asset, options);
|
title = new Title(renderer, screen, resource, asset, options, section);
|
||||||
setSection(title->run());
|
title->run();
|
||||||
delete title;
|
delete title;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1758,8 +1742,8 @@ void Director::runCredits()
|
|||||||
std::cout << "\n* SECTION: CREDITS" << std::endl;
|
std::cout << "\n* SECTION: CREDITS" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
credits = new Credits(renderer, screen, resource, asset, options);
|
credits = new Credits(renderer, screen, resource, asset, options, section);
|
||||||
setSection(credits->run());
|
credits->run();
|
||||||
delete credits;
|
delete credits;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1772,8 +1756,8 @@ void Director::runDemo()
|
|||||||
std::cout << "\n* SECTION: DEMO" << std::endl;
|
std::cout << "\n* SECTION: DEMO" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
demo = new Demo(renderer, screen, resource, asset, options, debug);
|
demo = new Demo(renderer, screen, resource, asset, options, section, debug);
|
||||||
setSection(demo->run());
|
demo->run();
|
||||||
delete demo;
|
delete demo;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1787,7 +1771,7 @@ void Director::runEnterID()
|
|||||||
}
|
}
|
||||||
// loadResources(section);
|
// loadResources(section);
|
||||||
enterID = new EnterID(renderer, screen, asset, options, section);
|
enterID = new EnterID(renderer, screen, asset, options, section);
|
||||||
setSection(enterID->run());
|
enterID->run();
|
||||||
delete enterID;
|
delete enterID;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1800,8 +1784,8 @@ void Director::runEnding()
|
|||||||
std::cout << "\n* SECTION: ENDING" << std::endl;
|
std::cout << "\n* SECTION: ENDING" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
ending = new Ending(renderer, screen, resource, asset, options);
|
ending = new Ending(renderer, screen, resource, asset, options, section);
|
||||||
setSection(ending->run());
|
ending->run();
|
||||||
delete ending;
|
delete ending;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1814,8 +1798,8 @@ void Director::runEnding2()
|
|||||||
std::cout << "\n* SECTION: ENDING2" << std::endl;
|
std::cout << "\n* SECTION: ENDING2" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
ending2 = new Ending2(renderer, screen, resource, asset, options);
|
ending2 = new Ending2(renderer, screen, resource, asset, options, section);
|
||||||
setSection(ending2->run());
|
ending2->run();
|
||||||
delete ending2;
|
delete ending2;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1828,8 +1812,8 @@ void Director::runGameOver()
|
|||||||
std::cout << "\n* SECTION: GAME OVER" << std::endl;
|
std::cout << "\n* SECTION: GAME OVER" << std::endl;
|
||||||
}
|
}
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
gameOver = new GameOver(renderer, screen, resource, asset, options);
|
gameOver = new GameOver(renderer, screen, resource, asset, options, section);
|
||||||
setSection(gameOver->run());
|
gameOver->run();
|
||||||
delete gameOver;
|
delete gameOver;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1843,8 +1827,8 @@ void Director::runGame()
|
|||||||
}
|
}
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
loadResources(section);
|
loadResources(section);
|
||||||
game = new Game(renderer, screen, resource, asset, options, input, debug);
|
game = new Game(renderer, screen, resource, asset, options, input, section, debug);
|
||||||
setSection(game->run());
|
game->run();
|
||||||
delete game;
|
delete game;
|
||||||
resource->free();
|
resource->free();
|
||||||
}
|
}
|
||||||
@@ -1852,9 +1836,9 @@ void Director::runGame()
|
|||||||
void Director::run()
|
void Director::run()
|
||||||
{
|
{
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
while (getSection() != SECTION_PROG_QUIT)
|
while (section->name != SECTION_PROG_QUIT)
|
||||||
{
|
{
|
||||||
switch (getSection())
|
switch (section->name)
|
||||||
{
|
{
|
||||||
case SECTION_PROG_LOGO:
|
case SECTION_PROG_LOGO:
|
||||||
runLogo();
|
runLogo();
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ private:
|
|||||||
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
|
||||||
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;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
section_t section; // Sección y subsección actual del programa;
|
JA_Music_t *music; // Musica del titulo
|
||||||
JA_Music_t* music; // Musica del titulo
|
|
||||||
std::string executablePath; // Path del ejecutable
|
std::string executablePath; // Path del ejecutable
|
||||||
std::string systemFolder; // Carpeta del sistema donde guardar datos
|
std::string systemFolder; // Carpeta del sistema donde guardar datos
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ private:
|
|||||||
void createSystemFolder();
|
void createSystemFolder();
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
void loadResources(section_t section);
|
void loadResources(section_t *section);
|
||||||
|
|
||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
bool setOptions(options_t *options, std::string var, std::string value);
|
bool setOptions(options_t *options, std::string var, std::string value);
|
||||||
@@ -89,15 +89,6 @@ private:
|
|||||||
// Crea el indice de ficheros
|
// Crea el indice de ficheros
|
||||||
bool setFileList();
|
bool setFileList();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 getSubsection();
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint8 getSection();
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setSection(section_t section);
|
|
||||||
|
|
||||||
// Ejecuta la seccion de juego con el logo
|
// Ejecuta la seccion de juego con el logo
|
||||||
void runLogo();
|
void runLogo();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "ending.h"
|
#include "ending.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -9,6 +9,7 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
|
|||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -19,8 +20,8 @@ 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_PROG_ENDING;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
scene = 0;
|
scene = 0;
|
||||||
@@ -150,7 +151,7 @@ void Ending::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ void Ending::checkEventHandler()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
case SDL_SCANCODE_B:
|
||||||
@@ -482,11 +483,11 @@ void Ending::iniScenes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t Ending::run()
|
void Ending::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_ENDING)
|
while (section->name == SECTION_PROG_ENDING)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
@@ -494,8 +495,6 @@ section_t Ending::run()
|
|||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
@@ -571,7 +570,7 @@ void Ending::checkChangeScene()
|
|||||||
if (scene == 5)
|
if (scene == 5)
|
||||||
{
|
{
|
||||||
// Termina el bucle
|
// Termina el bucle
|
||||||
section.name = SECTION_PROG_ENDING2;
|
section->name = SECTION_PROG_ENDING2;
|
||||||
|
|
||||||
// Mantiene los valores anteriores
|
// Mantiene los valores anteriores
|
||||||
scene = 4;
|
scene = 4;
|
||||||
|
|||||||
@@ -58,19 +58,19 @@ private:
|
|||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int coverCounter; // Contador para la cortinilla
|
int coverCounter; // Contador para la cortinilla
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::vector<endingTexture_t> spriteTexts; // Vector con los sprites de texto con su cortinilla
|
std::vector<endingTexture_t> spriteTexts; // Vector con los sprites de texto con su cortinilla
|
||||||
std::vector<endingTexture_t> spritePics; // Vector con los sprites de texto con su cortinilla
|
std::vector<endingTexture_t> spritePics; // Vector con los sprites de texto con su cortinilla
|
||||||
int scene; // Escena actual
|
int scene; // Escena actual
|
||||||
std::vector<scene_t> scenes; // Vector con los textos e imagenes de cada escena
|
std::vector<scene_t> scenes; // Vector con los textos e imagenes de cada escena
|
||||||
JA_Music_t* music; // Musica que suena durante el final
|
JA_Music_t *music; // Musica que suena durante el final
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -113,13 +113,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Ending();
|
~Ending();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -10,6 +10,7 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -21,8 +22,8 @@ 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_PROG_ENDING2;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
distSpriteText = 8;
|
distSpriteText = 8;
|
||||||
@@ -184,7 +185,7 @@ void Ending2::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +195,7 @@ void Ending2::checkEventHandler()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
case SDL_SCANCODE_B:
|
||||||
@@ -239,11 +240,11 @@ void Ending2::checkEventHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t Ending2::run()
|
void Ending2::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_ENDING2)
|
while (section->name == SECTION_PROG_ENDING2)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
@@ -251,8 +252,6 @@ section_t Ending2::run()
|
|||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
@@ -275,8 +274,8 @@ void Ending2::updateCounters()
|
|||||||
|
|
||||||
if (postCounter > 600)
|
if (postCounter > 600)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,16 +30,16 @@ private:
|
|||||||
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
||||||
std::vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
|
std::vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
|
||||||
std::vector<MovingSprite *> texts; // Vector con los sprites de texto
|
std::vector<MovingSprite *> texts; // Vector con los sprites de texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
bool counterEnabled; // Indica si está el contador habilitado
|
bool counterEnabled; // Indica si está el contador habilitado
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int postCounter; // Contador posterior
|
int postCounter; // Contador posterior
|
||||||
bool postCounterEnabled; // Indica si está habilitado el contador
|
bool postCounterEnabled; // Indica si está habilitado el contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
JA_Music_t* music; // Musica que suena durante el final
|
JA_Music_t *music; // Musica que suena durante el final
|
||||||
std::vector<std::string> spriteList; // Lista con todos los sprites a dibujar
|
std::vector<std::string> spriteList; // Lista con todos los sprites a dibujar
|
||||||
std::vector<color_t> colors; // Vector con los colores para el fade
|
std::vector<color_t> colors; // Vector con los colores para el fade
|
||||||
int maxSpriteWidth; // El valor de ancho del sprite mas ancho
|
int maxSpriteWidth; // El valor de ancho del sprite mas ancho
|
||||||
@@ -115,13 +115,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Ending2();
|
~Ending2();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,13 +5,14 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t section)
|
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -36,11 +37,10 @@ EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t
|
|||||||
pos = 0;
|
pos = 0;
|
||||||
name[pos] = 0;
|
name[pos] = 0;
|
||||||
maxLenght = 15;
|
maxLenght = 15;
|
||||||
this->section.subsection = section.subsection;
|
|
||||||
|
|
||||||
if (options->online.enabled && options->online.jailerID == "")
|
if (options->online.enabled && options->online.jailerID == "")
|
||||||
{
|
{
|
||||||
this->section.name = SECTION_PROG_ENTER_ID;
|
this->section->name = SECTION_PROG_ENTER_ID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -60,18 +60,16 @@ EnterID::~EnterID()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t EnterID::run()
|
void EnterID::run()
|
||||||
{
|
{
|
||||||
// Detiene la música
|
// Detiene la música
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_ENTER_ID)
|
while (section->name == SECTION_PROG_ENTER_ID)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
@@ -83,7 +81,7 @@ void EnterID::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +136,7 @@ void EnterID::checkEventHandler()
|
|||||||
|
|
||||||
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_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,6 +312,6 @@ void EnterID::initOnline()
|
|||||||
void EnterID::endSection()
|
void EnterID::endSection()
|
||||||
{
|
{
|
||||||
initOnline();
|
initOnline();
|
||||||
section.name = (section.subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE;
|
section->name = (section->subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
@@ -29,10 +29,10 @@ private:
|
|||||||
SDL_Texture *textTexture; // Textura para dibujar el texto
|
SDL_Texture *textTexture; // Textura para dibujar el texto
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
Texture *texture; // Textura para la fuente para el texto
|
Texture *texture; // Textura para la fuente para el texto
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::vector<captions_t> texts; // Vector con los textos
|
std::vector<captions_t> texts; // Vector con los textos
|
||||||
@@ -68,13 +68,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t section);
|
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~EnterID();
|
~EnterID();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug)
|
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
board.iniClock = SDL_GetTicks();
|
board.iniClock = SDL_GetTicks();
|
||||||
@@ -19,6 +19,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
this->input = input;
|
this->input = input;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
currentRoom = "01.room";
|
currentRoom = "01.room";
|
||||||
@@ -81,8 +82,8 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
initStats();
|
initStats();
|
||||||
stats->addVisit(room->getName());
|
stats->addVisit(room->getName());
|
||||||
|
|
||||||
section.name = SECTION_PROG_GAME;
|
section->name = SECTION_PROG_GAME;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::~Game()
|
Game::~Game()
|
||||||
@@ -112,7 +113,7 @@ void Game::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -127,7 +128,7 @@ void Game::checkEventHandler()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_TITLE;
|
section->name = SECTION_PROG_TITLE;
|
||||||
break;
|
break;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case SDL_SCANCODE_G:
|
case SDL_SCANCODE_G:
|
||||||
@@ -213,7 +214,7 @@ void Game::checkEventHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t Game::run()
|
void Game::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
if (!board.music)
|
if (!board.music)
|
||||||
@@ -221,15 +222,13 @@ section_t Game::run()
|
|||||||
JA_PauseMusic();
|
JA_PauseMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_GAME)
|
while (section->name == SECTION_PROG_GAME)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
@@ -432,7 +431,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_PROG_GAME_OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +568,7 @@ bool Game::checkEndGame()
|
|||||||
|
|
||||||
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_ENDING;
|
section->name = SECTION_PROG_ENDING;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ private:
|
|||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
Stats *stats; // Objeto encargado de gestionar las estadísticas
|
Stats *stats; // Objeto encargado de gestionar las estadísticas
|
||||||
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
|
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
|
||||||
|
section_t *section; // Seccion actual dentro del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
JA_Music_t *music; // Musica que suena durante el juego
|
JA_Music_t *music; // Musica que suena durante el juego
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
section_t section; // Seccion actual dentro del juego
|
|
||||||
std::string currentRoom; // Fichero de la habitación actual
|
std::string currentRoom; // Fichero de la habitación actual
|
||||||
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
||||||
JA_Sound_t *deathSound; // Sonido a reproducir cuando muere el jugador
|
JA_Sound_t *deathSound; // Sonido a reproducir cuando muere el jugador
|
||||||
@@ -140,13 +140,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);
|
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "game_over.h"
|
#include "game_over.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -9,6 +9,7 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A
|
|||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -20,8 +21,8 @@ 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_PROG_GAME_OVER;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
endSection = 400;
|
endSection = 400;
|
||||||
@@ -83,7 +84,7 @@ void GameOver::update()
|
|||||||
void GameOver::render()
|
void GameOver::render()
|
||||||
{
|
{
|
||||||
const int y = 32;
|
const int y = 32;
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
@@ -121,8 +122,8 @@ void GameOver::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +133,7 @@ void GameOver::checkEventHandler()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
case SDL_SCANCODE_B:
|
||||||
@@ -177,15 +178,13 @@ void GameOver::checkEventHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t GameOver::run()
|
void GameOver::run()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_GAME_OVER)
|
while (section->name == SECTION_PROG_GAME_OVER)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
@@ -195,7 +194,6 @@ void GameOver::updateColor()
|
|||||||
|
|
||||||
if (counter < half)
|
if (counter < half)
|
||||||
{
|
{
|
||||||
// const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
|
||||||
const float step = std::min(counter, fadeLenght) / (float)fadeLenght;
|
const float step = std::min(counter, fadeLenght) / (float)fadeLenght;
|
||||||
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
|
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
|
||||||
color = colors[index];
|
color = colors[index];
|
||||||
@@ -240,8 +238,8 @@ 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_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ private:
|
|||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
AnimatedSprite *playerSprite; // Sprite con el jugador
|
AnimatedSprite *playerSprite; // Sprite con el jugador
|
||||||
AnimatedSprite *tvSprite; // Sprite con el televisor
|
AnimatedSprite *tvSprite; // Sprite con el televisor
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::vector<color_t> colors; // Vector con los colores para el fade
|
std::vector<color_t> colors; // Vector con los colores para el fade
|
||||||
@@ -40,7 +40,7 @@ private:
|
|||||||
int endSection; // Contador: cuando acaba la sección
|
int endSection; // Contador: cuando acaba la sección
|
||||||
int iniFade; // Contador: cuando emiepza el fade
|
int iniFade; // Contador: cuando emiepza el fade
|
||||||
int fadeLenght; // Contador: duración del fade
|
int fadeLenght; // Contador: duración del fade
|
||||||
JA_Music_t* music; // Musica que suena durante el juego
|
JA_Music_t *music; // Musica que suena durante el juego
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -65,13 +65,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~GameOver();
|
~GameOver();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, 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;
|
||||||
@@ -9,6 +9,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -31,8 +32,8 @@ 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_PROG_INTRO;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
loadCounter = 0;
|
loadCounter = 0;
|
||||||
@@ -82,7 +83,7 @@ void Intro::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +93,7 @@ void Intro::checkEventHandler()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
case SDL_SCANCODE_B:
|
||||||
@@ -130,8 +131,8 @@ void Intro::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
section.name = SECTION_PROG_TITLE;
|
section->name = SECTION_PROG_TITLE;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,8 +180,8 @@ 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_PROG_TITLE;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,20 +241,19 @@ void Intro::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Intro::run()
|
void Intro::run()
|
||||||
{
|
{
|
||||||
// Inicia el sonido de carga
|
// Inicia el sonido de carga
|
||||||
JA_SetVolume(64);
|
JA_SetVolume(64);
|
||||||
JA_PlayMusic(loadingSound1);
|
JA_PlayMusic(loadingSound1);
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_INTRO)
|
while (section->name == SECTION_PROG_INTRO)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_SetVolume(128);
|
JA_SetVolume(128);
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ private:
|
|||||||
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
|
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
|
||||||
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
|
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int preCounter; // Contador previo para realizar una pausa inicial
|
int preCounter; // Contador previo para realizar una pausa inicial
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
int loadCounter; // Contador para controlar las cargas
|
int loadCounter; // Contador para controlar las cargas
|
||||||
@@ -68,13 +68,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Intro();
|
~Intro();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, int subsection)
|
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, 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;
|
||||||
@@ -10,6 +10,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -37,8 +38,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_PROG_LOGO;
|
||||||
section.subsection = subsection;
|
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
initFade = 300;
|
initFade = 300;
|
||||||
@@ -77,7 +77,7 @@ void Logo::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ void Logo::checkEventHandler()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
case SDL_SCANCODE_B:
|
||||||
@@ -125,7 +125,7 @@ void Logo::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
endSection();
|
endSection();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -175,26 +175,32 @@ void Logo::updateTextureColors()
|
|||||||
{
|
{
|
||||||
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 1)
|
else if (counter == ini + inc * 1)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 2)
|
else if (counter == ini + inc * 2)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 3)
|
else if (counter == ini + inc * 3)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 4)
|
else if (counter == ini + inc * 4)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 5)
|
else if (counter == ini + inc * 5)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 6)
|
else if (counter == ini + inc * 6)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
@@ -210,31 +216,37 @@ void Logo::updateTextureColors()
|
|||||||
texture->setColor(color[6].r, color[6].g, color[6].b);
|
texture->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 1)
|
else if (counter == initFade + inc * 1)
|
||||||
{
|
{
|
||||||
texture->setColor(color[5].r, color[5].g, color[5].b);
|
texture->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 2)
|
else if (counter == initFade + inc * 2)
|
||||||
{
|
{
|
||||||
texture->setColor(color[4].r, color[4].g, color[4].b);
|
texture->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 3)
|
else if (counter == initFade + inc * 3)
|
||||||
{
|
{
|
||||||
texture->setColor(color[3].r, color[3].g, color[3].b);
|
texture->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 4)
|
else if (counter == initFade + inc * 4)
|
||||||
{
|
{
|
||||||
texture->setColor(color[2].r, color[2].g, color[2].b);
|
texture->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 5)
|
else if (counter == initFade + inc * 5)
|
||||||
{
|
{
|
||||||
texture->setColor(color[1].r, color[1].g, color[1].b);
|
texture->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 6)
|
else if (counter == initFade + inc * 6)
|
||||||
{
|
{
|
||||||
texture->setColor(color[0].r, color[0].g, color[0].b);
|
texture->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
@@ -295,18 +307,16 @@ void Logo::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Logo::run()
|
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_PROG_LOGO)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
@@ -318,5 +328,5 @@ void Logo::switchPalette()
|
|||||||
// Termina la sección
|
// Termina la sección
|
||||||
void Logo::endSection()
|
void Logo::endSection()
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_ENTER_ID;
|
section->name = SECTION_PROG_ENTER_ID;
|
||||||
}
|
}
|
||||||
@@ -27,11 +27,11 @@ private:
|
|||||||
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||||
Sprite *sprite2; // Sprite para manejar la textura2
|
Sprite *sprite2; // Sprite para manejar la textura2
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
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
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
int initFade; // Tiempo del contador cuando inicia el fade a negro
|
int initFade; // Tiempo del contador cuando inicia el fade a negro
|
||||||
@@ -61,13 +61,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, int subsection);
|
Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Logo();
|
~Logo();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "title.h"
|
#include "title.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
|
Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, 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;
|
||||||
@@ -9,6 +9,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
|
this->section = section;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -25,8 +26,8 @@ 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_PROG_TITLE;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
||||||
@@ -79,7 +80,7 @@ void Title::checkEventHandler()
|
|||||||
// 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_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,19 +89,19 @@ void Title::checkEventHandler()
|
|||||||
{
|
{
|
||||||
if (eventHandler->type == SDL_JOYBUTTONDOWN)
|
if (eventHandler->type == SDL_JOYBUTTONDOWN)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_GAME;
|
section->name = SECTION_PROG_GAME;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
section.name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_RETURN:
|
case SDL_SCANCODE_RETURN:
|
||||||
section.name = SECTION_PROG_GAME;
|
section->name = SECTION_PROG_GAME;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_B:
|
case SDL_SCANCODE_B:
|
||||||
@@ -210,8 +211,8 @@ void Title::update()
|
|||||||
// Comprueba si ha terminado la marquesina y acaba con el titulo
|
// Comprueba si ha terminado la marquesina y acaba con el titulo
|
||||||
if (letters[letters.size() - 1].x < -10)
|
if (letters[letters.size() - 1].x < -10)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_CREDITS;
|
section->name = SECTION_PROG_CREDITS;
|
||||||
section.subsection = 0;
|
section->subsection = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,15 +240,13 @@ void Title::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
section_t Title::run()
|
void Title::run()
|
||||||
{
|
{
|
||||||
while (section.name == SECTION_PROG_TITLE)
|
while (section->name == SECTION_PROG_TITLE)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recarga las texturas
|
// Recarga las texturas
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ private:
|
|||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
Texture *pressEnterTexture; // Textura con los graficos de PRESS ENTER
|
Texture *pressEnterTexture; // Textura con los graficos de PRESS ENTER
|
||||||
Sprite *pressEnterSprite; // Sprite para manejar la textura de PRESS ENTER
|
Sprite *pressEnterSprite; // Sprite para manejar la textura de PRESS ENTER
|
||||||
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
std::string longText; // Texto que aparece en la parte inferior del titulo
|
std::string longText; // Texto que aparece en la parte inferior del titulo
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
@@ -69,13 +69,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Title();
|
~Title();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
section_t run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user