Añadido enter_id.cpp
Cambiados los defines de nombre de secciones y subsecciones
This commit is contained in:
@@ -126,11 +126,9 @@ namespace jscore {
|
||||
return score.size();
|
||||
}
|
||||
string getUserName(const int index) {
|
||||
if (score.size()==0 || index >= (int)score.size()) return "";
|
||||
return score[index].name;
|
||||
}
|
||||
const int getPoints(const int index) {
|
||||
if (score.size()==0 || index >= (int)score.size()) return 0;
|
||||
return score[index].points;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,21 +38,21 @@ const int GAMECANVAS_FIRST_QUARTER_Y = GAMECANVAS_HEIGHT / 4;
|
||||
const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
|
||||
|
||||
// Secciones del programa
|
||||
#define PROG_SECTION_LOGO 0
|
||||
#define PROG_SECTION_INTRO 1
|
||||
#define PROG_SECTION_TITLE 2
|
||||
#define PROG_SECTION_GAME 3
|
||||
#define PROG_SECTION_QUIT 4
|
||||
#define SECTION_PROG_LOGO 0
|
||||
#define SECTION_PROG_INTRO 1
|
||||
#define SECTION_PROG_TITLE 2
|
||||
#define SECTION_PROG_GAME 3
|
||||
#define SECTION_PROG_QUIT 4
|
||||
|
||||
// Subsecciones
|
||||
#define GAME_SECTION_PLAY_1P 0
|
||||
#define GAME_SECTION_PLAY_2P 1
|
||||
#define GAME_SECTION_PAUSE 2
|
||||
#define GAME_SECTION_GAMEOVER 3
|
||||
#define TITLE_SECTION_1 3
|
||||
#define TITLE_SECTION_2 4
|
||||
#define TITLE_SECTION_3 5
|
||||
#define TITLE_SECTION_INSTRUCTIONS 6
|
||||
#define SUBSECTION_GAME_PLAY_1P 0
|
||||
#define SUBSECTION_GAME_PLAY_2P 1
|
||||
#define SUBSECTION_GAME_PAUSE 2
|
||||
#define SUBSECTION_GAME_GAMEOVER 3
|
||||
#define SUBSECTION_TITLE_1 3
|
||||
#define SUBSECTION_TITLE_2 4
|
||||
#define SUBSECTION_TITLE_3 5
|
||||
#define SUBSECTION_TITLE_INSTRUCTIONS 6
|
||||
|
||||
// Ningun tipo
|
||||
#define NO_KIND 0
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
Director::Director(int argc, char *argv[])
|
||||
{
|
||||
// Inicializa variables
|
||||
section.name = PROG_SECTION_LOGO;
|
||||
section.name = SECTION_PROG_LOGO;
|
||||
|
||||
// Inicializa las opciones del programa
|
||||
initOptions();
|
||||
@@ -691,7 +691,7 @@ void Director::runTitle()
|
||||
|
||||
void Director::runGame()
|
||||
{
|
||||
const int numPlayers = section.subsection == GAME_SECTION_PLAY_1P ? 1 : 2;
|
||||
const int numPlayers = section.subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
||||
game = new Game(numPlayers, 0, renderer, screen, asset, lang, input, false, options);
|
||||
setSection(game->run());
|
||||
delete game;
|
||||
@@ -700,23 +700,23 @@ void Director::runGame()
|
||||
void Director::run()
|
||||
{
|
||||
// Bucle principal
|
||||
while (section.name != PROG_SECTION_QUIT)
|
||||
while (section.name != SECTION_PROG_QUIT)
|
||||
{
|
||||
switch (section.name)
|
||||
{
|
||||
case PROG_SECTION_LOGO:
|
||||
case SECTION_PROG_LOGO:
|
||||
runLogo();
|
||||
break;
|
||||
|
||||
case PROG_SECTION_INTRO:
|
||||
case SECTION_PROG_INTRO:
|
||||
runIntro();
|
||||
break;
|
||||
|
||||
case PROG_SECTION_TITLE:
|
||||
case SECTION_PROG_TITLE:
|
||||
runTitle();
|
||||
break;
|
||||
|
||||
case PROG_SECTION_GAME:
|
||||
case SECTION_PROG_GAME:
|
||||
runGame();
|
||||
break;
|
||||
}
|
||||
|
||||
306
source/enter_id.cpp
Normal file
306
source/enter_id.cpp
Normal file
@@ -0,0 +1,306 @@
|
||||
#include "common/jail_audio.h"
|
||||
#include "common/jscore.h"
|
||||
#include "const.h"
|
||||
#include "enter_id.h"
|
||||
#include <iostream>
|
||||
|
||||
// Constructor
|
||||
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options)
|
||||
{
|
||||
// Copia la dirección de los objetos
|
||||
this->renderer = renderer;
|
||||
this->screen = screen;
|
||||
this->asset = asset;
|
||||
this->options = options;
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
eventHandler = new SDL_Event();
|
||||
texture = new Texture(renderer, asset->get("smb2.png"));
|
||||
text = new Text(asset->get("smb2.txt"), texture, renderer);
|
||||
|
||||
// Crea la textura para el texto que se escribe en pantalla
|
||||
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||
if (textTexture == nullptr)
|
||||
{
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Inicializa variables
|
||||
loopRunning = true;
|
||||
counter = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
pos = 0;
|
||||
name[pos] = 0;
|
||||
maxLenght = 15;
|
||||
|
||||
if (options->online.enabled && options->online.jailerID == "")
|
||||
{
|
||||
loopRunning = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
endSection();
|
||||
}
|
||||
|
||||
// Escribe el texto en la textura
|
||||
fillTexture();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
EnterID::~EnterID()
|
||||
{
|
||||
delete eventHandler;
|
||||
delete text;
|
||||
delete texture;
|
||||
}
|
||||
|
||||
// Bucle para el logo del juego
|
||||
void EnterID::run()
|
||||
{
|
||||
// Detiene la música
|
||||
JA_StopMusic();
|
||||
|
||||
while (loopRunning)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el manejador de eventos
|
||||
void EnterID::checkEvents()
|
||||
{
|
||||
// Comprueba los eventos que hay en la cola
|
||||
while (SDL_PollEvent(eventHandler) != 0)
|
||||
{
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
loopRunning = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// El ENTER solo se comprueba cuando se suelta, para no saltarse la siguiente sección
|
||||
if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP))
|
||||
{
|
||||
if (eventHandler->key.keysym.scancode == SDL_SCANCODE_RETURN)
|
||||
{
|
||||
options->online.jailerID = (std::string)name;
|
||||
endSection();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba las teclas que se han pulsado
|
||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
||||
{
|
||||
if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_A && eventHandler->key.keysym.scancode <= SDL_SCANCODE_Z)
|
||||
{ // Si pulsa una letra
|
||||
if (pos < maxLenght)
|
||||
{
|
||||
name[pos++] = eventHandler->key.keysym.scancode + 61;
|
||||
name[pos] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_1 && eventHandler->key.keysym.scancode <= SDL_SCANCODE_9)
|
||||
{ // Si pulsa un número
|
||||
if (pos < maxLenght)
|
||||
{ // En ascii el '0' va antes del '1', pero en scancode el '0' va despues de '9'
|
||||
name[pos++] = eventHandler->key.keysym.scancode + 19;
|
||||
name[pos] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_0)
|
||||
{
|
||||
if (pos < maxLenght)
|
||||
{
|
||||
name[pos++] = 48;
|
||||
name[pos] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_BACKSPACE)
|
||||
{
|
||||
if (pos > 0)
|
||||
{
|
||||
name[--pos] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
|
||||
{
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F1)
|
||||
{
|
||||
screen->setWindowSize(1);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F2)
|
||||
{
|
||||
screen->setWindowSize(2);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F3)
|
||||
{
|
||||
screen->setWindowSize(3);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F4)
|
||||
{
|
||||
screen->setWindowSize(4);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F5)
|
||||
{
|
||||
switchPalette();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las variables
|
||||
void EnterID::update()
|
||||
{
|
||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||
{
|
||||
// Actualiza el contador de ticks
|
||||
ticks = SDL_GetTicks();
|
||||
|
||||
// Actualiza el contador
|
||||
counter++;
|
||||
|
||||
// Actualiza el cursor
|
||||
cursor = (counter % 20 >= 10) ? " " : "_";
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja en pantalla
|
||||
void EnterID::render()
|
||||
{
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean();
|
||||
|
||||
// Dibuja la textura con el texto en pantalla
|
||||
SDL_RenderCopy(renderer, textTexture, nullptr, nullptr);
|
||||
|
||||
// Escribe el jailerID
|
||||
const std::string jailerID = (std::string)name + cursor;
|
||||
const color_t color = stringToColor(options->palette, "white");
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, (16 * 8 + 1), jailerID, 1, color);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
}
|
||||
|
||||
// Inicializa los textos
|
||||
void EnterID::iniTexts()
|
||||
{
|
||||
texts.clear();
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "red")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"YOU HAVE NOT SPECIFIED ANY ID", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"FOR THE ONLINE SERVICE", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"PLEASE ENTER AN ID OR", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"LEAVE BLANK FOR OFFLINE MODE", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"JAILER_ID:", stringToColor(options->palette, "red")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
}
|
||||
|
||||
// Escribe el texto en la textura
|
||||
void EnterID::fillTexture()
|
||||
{
|
||||
// Inicializa los textos
|
||||
iniTexts();
|
||||
|
||||
// Rellena la textura de texto
|
||||
SDL_SetRenderTarget(renderer, textTexture);
|
||||
color_t c = stringToColor(options->palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Escribe el texto en la textura
|
||||
const int size = text->getCharacterSize();
|
||||
int i = 0;
|
||||
|
||||
for (auto t : texts)
|
||||
{
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR, PLAY_AREA_CENTER_X, i * size, t.label, 1, t.color);
|
||||
i++;
|
||||
}
|
||||
|
||||
SDL_SetRenderTarget(renderer, nullptr);
|
||||
}
|
||||
|
||||
// Inicializa los servicios online
|
||||
void EnterID::initOnline()
|
||||
{
|
||||
if (options->online.sessionEnabled)
|
||||
{ // Si ya ha iniciado la sesión, que no continue
|
||||
return;
|
||||
}
|
||||
|
||||
if (options->online.jailerID == "")
|
||||
{ // Jailer ID no definido
|
||||
options->online.enabled = false;
|
||||
}
|
||||
else
|
||||
{ // Jailer ID iniciado
|
||||
options->online.enabled = options->online.sessionEnabled = true;
|
||||
jscore::init(options->online.server, options->online.port);
|
||||
|
||||
#ifdef DEBUG
|
||||
const std::string caption = "IS LOGGED IN (DEBUG)";
|
||||
#else
|
||||
const std::string caption = "IS LOGGED IN";
|
||||
#endif
|
||||
screen->showNotification(options->online.jailerID, caption, 12);
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << caption << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Termina la sección
|
||||
void EnterID::endSection()
|
||||
{
|
||||
loopRunning = false;
|
||||
initOnline();
|
||||
}
|
||||
78
source/enter_id.h
Normal file
78
source/enter_id.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "common/asset.h"
|
||||
#include "common/screen.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/text.h"
|
||||
#include "common/texture.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef ENTER_ID_H
|
||||
#define ENTER_ID_H
|
||||
|
||||
class EnterID
|
||||
{
|
||||
private:
|
||||
struct captions_t
|
||||
{
|
||||
std::string label; // Texto a escribir
|
||||
color_t color; // Color del texto
|
||||
};
|
||||
|
||||
// Punteros y objetos
|
||||
Asset *asset; // Objeto con los ficheros de recursos
|
||||
options_t *options; // Puntero a las opciones del juego
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
SDL_Texture *textTexture; // Textura para dibujar el texto
|
||||
Text *text; // Objeto para escribir texto en pantalla
|
||||
Texture *texture; // Textura para la fuente para el texto
|
||||
|
||||
// Variables
|
||||
bool loopRunning; // Indica si ha de terminar el bucle principal
|
||||
int counter; // Contador
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
std::vector<captions_t> texts; // Vector con los textos
|
||||
std::string cursor; // Contiene el caracter que se muestra como cursor
|
||||
|
||||
char name[15];
|
||||
int pos;
|
||||
int maxLenght; // Tamaño máximo del jailerID
|
||||
|
||||
// Actualiza las variables
|
||||
void update();
|
||||
|
||||
// Dibuja en pantalla
|
||||
void render();
|
||||
|
||||
// Comprueba el manejador de eventos
|
||||
void checkEvents();
|
||||
|
||||
// Inicializa los textos
|
||||
void iniTexts();
|
||||
|
||||
// Escribe el texto en la textura
|
||||
void fillTexture();
|
||||
|
||||
// Inicializa los servicios online
|
||||
void initOnline();
|
||||
|
||||
// Termina la sección
|
||||
void endSection();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options);
|
||||
|
||||
// Destructor
|
||||
~EnterID();
|
||||
|
||||
// Bucle principal
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -246,8 +246,8 @@ void Game::init()
|
||||
|
||||
gameCompleted = false;
|
||||
gameCompletedCounter = 0;
|
||||
section.name = PROG_SECTION_GAME;
|
||||
section.subsection = GAME_SECTION_PLAY_1P;
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.subsection = SUBSECTION_GAME_PLAY_1P;
|
||||
menaceCurrent = 0;
|
||||
menaceThreshold = 0;
|
||||
hiScoreAchieved = false;
|
||||
@@ -1767,7 +1767,7 @@ void Game::updatePlayers()
|
||||
{
|
||||
if (demo.enabled)
|
||||
{
|
||||
section = {PROG_SECTION_TITLE, TITLE_SECTION_INSTRUCTIONS};
|
||||
section = {SECTION_PROG_TITLE, SUBSECTION_TITLE_INSTRUCTIONS};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1866,7 +1866,7 @@ void Game::updateDeath()
|
||||
}
|
||||
else
|
||||
{
|
||||
section.subsection = GAME_SECTION_GAMEOVER;
|
||||
section.subsection = SUBSECTION_GAME_GAMEOVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3089,7 +3089,7 @@ void Game::checkGameInput()
|
||||
// Comprueba el input de pausa
|
||||
if (input->checkInput(input_pause, REPEAT_FALSE))
|
||||
{
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
}
|
||||
|
||||
// Incrementa el contador de la demo
|
||||
@@ -3099,7 +3099,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
else
|
||||
{
|
||||
section = {PROG_SECTION_TITLE, TITLE_SECTION_INSTRUCTIONS};
|
||||
section = {SECTION_PROG_TITLE, SUBSECTION_TITLE_INSTRUCTIONS};
|
||||
}
|
||||
}
|
||||
// Modo Demo no activo
|
||||
@@ -3182,7 +3182,7 @@ void Game::checkGameInput()
|
||||
// Comprueba el input de pausa
|
||||
if (input->checkInput(input_cancel, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
||||
{
|
||||
section.subsection = GAME_SECTION_PAUSE;
|
||||
section.subsection = SUBSECTION_GAME_PAUSE;
|
||||
}
|
||||
|
||||
if (demo.counter < TOTAL_DEMO_DATA)
|
||||
@@ -3195,7 +3195,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
else if (demo.recording)
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
i++;
|
||||
@@ -3341,22 +3341,22 @@ void Game::shakeScreen()
|
||||
// Bucle para el juego
|
||||
section_t Game::run()
|
||||
{
|
||||
while (section.name == PROG_SECTION_GAME)
|
||||
while (section.name == SECTION_PROG_GAME)
|
||||
{
|
||||
// Sección juego en pausa
|
||||
if (section.subsection == GAME_SECTION_PAUSE)
|
||||
if (section.subsection == SUBSECTION_GAME_PAUSE)
|
||||
{
|
||||
runPausedGame();
|
||||
}
|
||||
|
||||
// Sección Game Over
|
||||
if (section.subsection == GAME_SECTION_GAMEOVER)
|
||||
if (section.subsection == SUBSECTION_GAME_GAMEOVER)
|
||||
{
|
||||
runGameOverScreen();
|
||||
}
|
||||
|
||||
// Sección juego jugando
|
||||
if ((section.subsection == GAME_SECTION_PLAY_1P) || (section.subsection == GAME_SECTION_PLAY_2P))
|
||||
if ((section.subsection == SUBSECTION_GAME_PLAY_1P) || (section.subsection == SUBSECTION_GAME_PLAY_2P))
|
||||
{
|
||||
// Si la música no está sonando
|
||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||
@@ -3412,8 +3412,8 @@ void Game::updatePausedGame()
|
||||
}
|
||||
else
|
||||
{ // Ha finalizado el contador
|
||||
section.name = PROG_SECTION_GAME;
|
||||
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.subsection = numPlayers == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P;
|
||||
|
||||
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
|
||||
{
|
||||
@@ -3448,8 +3448,8 @@ void Game::updatePausedGame()
|
||||
fade->update();
|
||||
if (fade->hasEnded())
|
||||
{
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
JA_StopMusic();
|
||||
}
|
||||
}
|
||||
@@ -3519,7 +3519,7 @@ void Game::runPausedGame()
|
||||
// Inicializa variables
|
||||
pauseCounter = 90;
|
||||
|
||||
while ((section.subsection == GAME_SECTION_PAUSE) && (section.name == PROG_SECTION_GAME))
|
||||
while ((section.subsection == SUBSECTION_GAME_PAUSE) && (section.name == SECTION_PROG_GAME))
|
||||
{
|
||||
updatePausedGame();
|
||||
checkEvents();
|
||||
@@ -3554,15 +3554,15 @@ void Game::updateGameOverScreen()
|
||||
switch (postFade)
|
||||
{
|
||||
case 0: // YES
|
||||
section.name = PROG_SECTION_GAME;
|
||||
section.name = SECTION_PROG_GAME;
|
||||
deleteAllVectorObjects();
|
||||
init();
|
||||
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
||||
section.subsection = numPlayers == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P;
|
||||
break;
|
||||
|
||||
case 1: // NO
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -3600,7 +3600,7 @@ void Game::updateGameOverScreen()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||
@@ -3693,7 +3693,7 @@ void Game::runGameOverScreen()
|
||||
// Reinicia el menu
|
||||
gameOverMenu->reset();
|
||||
|
||||
while ((section.subsection == GAME_SECTION_GAMEOVER) && (section.name == PROG_SECTION_GAME))
|
||||
while ((section.subsection == SUBSECTION_GAME_GAMEOVER) && (section.name == SECTION_PROG_GAME))
|
||||
{
|
||||
updateGameOverScreen();
|
||||
renderGameOverScreen();
|
||||
@@ -3806,7 +3806,7 @@ void Game::updateGameCompleted()
|
||||
|
||||
if (gameCompletedCounter == GAME_COMPLETED_END)
|
||||
{
|
||||
section.subsection = GAME_SECTION_GAMEOVER;
|
||||
section.subsection = SUBSECTION_GAME_GAMEOVER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3864,7 +3864,7 @@ void Game::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3872,7 +3872,7 @@ void Game::checkEvents()
|
||||
{
|
||||
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
{
|
||||
section.subsection = GAME_SECTION_PAUSE;
|
||||
section.subsection = SUBSECTION_GAME_PAUSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ void HiScoreTable::update()
|
||||
|
||||
if (counter == counterEnd)
|
||||
{
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -78,8 +78,8 @@ void HiScoreTable::update()
|
||||
|
||||
if (manualQuit)
|
||||
{
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_3;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ void HiScoreTable::checkEventHandler()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void HiScoreTable::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||
@@ -214,8 +214,8 @@ void HiScoreTable::checkInput()
|
||||
if (mode == mhst_auto)
|
||||
{
|
||||
JA_StopMusic();
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -88,8 +88,8 @@ void Instructions::update()
|
||||
|
||||
if (counter == counterEnd)
|
||||
{
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -98,8 +98,8 @@ void Instructions::update()
|
||||
|
||||
if (manualQuit)
|
||||
{
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_3;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ void Instructions::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void Instructions::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||
@@ -248,8 +248,8 @@ void Instructions::checkInput()
|
||||
if (mode == m_auto)
|
||||
{
|
||||
JA_StopMusic();
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input,
|
||||
loadMedia();
|
||||
|
||||
// Inicializa variables
|
||||
section.name = PROG_SECTION_INTRO;
|
||||
section.name = SECTION_PROG_INTRO;
|
||||
section.subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
@@ -181,7 +181,7 @@ void Intro::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ void Intro::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||
@@ -213,8 +213,8 @@ void Intro::checkInput()
|
||||
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE))
|
||||
{
|
||||
JA_StopMusic();
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,8 +363,8 @@ void Intro::updateScenes()
|
||||
bitmaps[5]->setEnabled(false);
|
||||
texts[8]->setEnabled(false);
|
||||
JA_StopMusic();
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -432,7 +432,7 @@ section_t Intro::run()
|
||||
{
|
||||
JA_PlayMusic(music, 0);
|
||||
|
||||
while (section.name == PROG_SECTION_INTRO)
|
||||
while (section.name == SECTION_PROG_INTRO)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
|
||||
@@ -19,7 +19,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
|
||||
|
||||
// Inicializa variables
|
||||
counter = 0;
|
||||
section.name = PROG_SECTION_LOGO;
|
||||
section.name = SECTION_PROG_LOGO;
|
||||
section.subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
@@ -40,7 +40,7 @@ void Logo::checkLogoEnd()
|
||||
{
|
||||
if (counter >= END_LOGO + 20)
|
||||
{
|
||||
section.name = PROG_SECTION_INTRO;
|
||||
section.name = SECTION_PROG_INTRO;
|
||||
section.subsection = 0;
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ void Logo::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ void Logo::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||
@@ -85,8 +85,8 @@ void Logo::checkInput()
|
||||
|
||||
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE))
|
||||
{
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ section_t Logo::run()
|
||||
{
|
||||
JA_StopMusic();
|
||||
|
||||
while (section.name == PROG_SECTION_LOGO)
|
||||
while (section.name == SECTION_PROG_LOGO)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
|
||||
@@ -95,13 +95,13 @@ Title::~Title()
|
||||
void Title::init()
|
||||
{
|
||||
// Inicializa variables
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
counter = TITLE_COUNTER;
|
||||
backgroundCounter = 0;
|
||||
backgroundMode = rand() % 2;
|
||||
menuVisible = false;
|
||||
menu.active = menu.title;
|
||||
nextSection.name = PROG_SECTION_GAME;
|
||||
nextSection.name = SECTION_PROG_GAME;
|
||||
postFade = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
@@ -230,7 +230,7 @@ void Title::update()
|
||||
switch (section.subsection)
|
||||
{
|
||||
// Sección 1 - Titulo desplazandose
|
||||
case TITLE_SECTION_1:
|
||||
case SUBSECTION_TITLE_1:
|
||||
{
|
||||
// Actualiza los objetos
|
||||
coffeeBitmap->update();
|
||||
@@ -239,7 +239,7 @@ void Title::update()
|
||||
// Si los objetos han llegado a su destino, cambiamos de Sección
|
||||
if (coffeeBitmap->hasFinished() && crisisBitmap->hasFinished())
|
||||
{
|
||||
section.subsection = TITLE_SECTION_2;
|
||||
section.subsection = SUBSECTION_TITLE_2;
|
||||
|
||||
// Pantallazo blanco
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
@@ -253,7 +253,7 @@ void Title::update()
|
||||
break;
|
||||
|
||||
// Sección 2 - Titulo vibrando
|
||||
case TITLE_SECTION_2:
|
||||
case SUBSECTION_TITLE_2:
|
||||
{
|
||||
// Agita la pantalla
|
||||
static const int v[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0};
|
||||
@@ -270,13 +270,13 @@ void Title::update()
|
||||
|
||||
if (step == 33)
|
||||
{
|
||||
section.subsection = TITLE_SECTION_3;
|
||||
section.subsection = SUBSECTION_TITLE_3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Sección 3 - La pantalla de titulo con el menú y la música
|
||||
case TITLE_SECTION_3:
|
||||
case SUBSECTION_TITLE_3:
|
||||
{
|
||||
if (counter > 0)
|
||||
{ // Reproduce la música
|
||||
@@ -296,19 +296,19 @@ void Title::update()
|
||||
switch (postFade)
|
||||
{
|
||||
case 0: // 1 PLAYER
|
||||
section.name = PROG_SECTION_GAME;
|
||||
section.subsection = GAME_SECTION_PLAY_1P;
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.subsection = SUBSECTION_GAME_PLAY_1P;
|
||||
JA_StopMusic();
|
||||
break;
|
||||
|
||||
case 1: // 2 PLAYERS
|
||||
section.name = PROG_SECTION_GAME;
|
||||
section.subsection = GAME_SECTION_PLAY_2P;
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.subsection = SUBSECTION_GAME_PLAY_2P;
|
||||
JA_StopMusic();
|
||||
break;
|
||||
|
||||
case 2: // QUIT
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
JA_StopMusic();
|
||||
break;
|
||||
|
||||
@@ -318,17 +318,17 @@ void Title::update()
|
||||
if (demo)
|
||||
{
|
||||
runDemoGame();
|
||||
if (section.name != PROG_SECTION_QUIT)
|
||||
if (section.name != SECTION_PROG_QUIT)
|
||||
{
|
||||
runInstructions(m_auto);
|
||||
}
|
||||
if (section.name != PROG_SECTION_QUIT)
|
||||
if (section.name != SECTION_PROG_QUIT)
|
||||
{
|
||||
runHiScoreTable(mhst_auto);
|
||||
}
|
||||
}
|
||||
else
|
||||
section.name = PROG_SECTION_LOGO;
|
||||
section.name = SECTION_PROG_LOGO;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -507,11 +507,11 @@ void Title::update()
|
||||
if (demo)
|
||||
{
|
||||
runDemoGame();
|
||||
if (section.name != PROG_SECTION_QUIT)
|
||||
if (section.name != SECTION_PROG_QUIT)
|
||||
{
|
||||
runInstructions(m_auto);
|
||||
}
|
||||
if (section.name != PROG_SECTION_QUIT)
|
||||
if (section.name != SECTION_PROG_QUIT)
|
||||
{
|
||||
runHiScoreTable(mhst_auto);
|
||||
}
|
||||
@@ -521,12 +521,12 @@ void Title::update()
|
||||
}
|
||||
else
|
||||
{
|
||||
section.name = PROG_SECTION_LOGO;
|
||||
section.name = SECTION_PROG_LOGO;
|
||||
}
|
||||
}
|
||||
|
||||
// Sección Instrucciones
|
||||
if (section.subsection == TITLE_SECTION_INSTRUCTIONS)
|
||||
if (section.subsection == SUBSECTION_TITLE_INSTRUCTIONS)
|
||||
{
|
||||
runInstructions(m_auto);
|
||||
counter = TITLE_COUNTER;
|
||||
@@ -548,7 +548,7 @@ void Title::render()
|
||||
switch (section.subsection)
|
||||
{
|
||||
// Sección 1 - Titulo desplazandose
|
||||
case TITLE_SECTION_1:
|
||||
case SUBSECTION_TITLE_1:
|
||||
{
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
@@ -572,7 +572,7 @@ void Title::render()
|
||||
break;
|
||||
|
||||
// Sección 2 - Titulo vibrando
|
||||
case TITLE_SECTION_2:
|
||||
case SUBSECTION_TITLE_2:
|
||||
{ // Reproduce el efecto sonoro
|
||||
JA_PlaySound(crashSound);
|
||||
|
||||
@@ -609,13 +609,13 @@ void Title::render()
|
||||
screen->blit();
|
||||
}
|
||||
|
||||
section.subsection = TITLE_SECTION_3;
|
||||
section.subsection = SUBSECTION_TITLE_3;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Sección 3 - La pantalla de titulo con el menú y la música
|
||||
case TITLE_SECTION_3:
|
||||
case SUBSECTION_TITLE_3:
|
||||
{ // Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
|
||||
@@ -675,7 +675,7 @@ void Title::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -684,7 +684,7 @@ void Title::checkEvents()
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
if (section.subsection == TITLE_SECTION_3)
|
||||
if (section.subsection == SUBSECTION_TITLE_3)
|
||||
{ // Si se pulsa alguna tecla durante la tercera sección del titulo
|
||||
if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP))
|
||||
{
|
||||
@@ -703,7 +703,7 @@ void Title::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||
@@ -970,7 +970,7 @@ void Title::applyOptions()
|
||||
// Bucle para el titulo del juego
|
||||
section_t Title::run()
|
||||
{
|
||||
while (section.name == PROG_SECTION_TITLE)
|
||||
while (section.name == SECTION_PROG_TITLE)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
@@ -995,8 +995,8 @@ section_t Title::runHiScoreTable(mode_hiScoreTable_e mode)
|
||||
{
|
||||
if (!options->online.enabled)
|
||||
{
|
||||
section.name = PROG_SECTION_TITLE;
|
||||
section.subsection = TITLE_SECTION_1;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = SUBSECTION_TITLE_1;
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user