Eliminado el menu de pausa

Eliminado el menu de game over
Eliminado el menu de seleccionar jugador
Se puede poner pausa y salir del juego desde ambos mandos
This commit is contained in:
2024-06-30 15:08:25 +02:00
parent 1754cfb93a
commit addc8241ab
11 changed files with 73 additions and 543 deletions

View File

@@ -1,29 +0,0 @@
font_png=smb2.png
font_txt=smb2.txt
sound_move=menu_move.wav
sound_accept=menu_select.wav
name=GAME OVER
x=0
y=120
backgroundType=0
backgroundColor=128,64,0,0
areElementsCenteredOnX=true
isCenteredOnX=true
centerX=199
selector_color=255,122,0,255
selector_text_color=255,255,235
defaultActionWhenCancel=1
[item]
text=SI
hPaddingDown=2
[/item]
[item]
text=NO
[/item]

View File

@@ -1,35 +0,0 @@
font_png=smb2.png
font_txt=smb2.txt
sound_move=menu_move.wav
sound_accept=menu_select.wav
name=PAUSE
x=0
y=80
backgroundType=1
backgroundColor=41,57,65,240
areElementsCenteredOnX=true
isCenteredOnX=true
centerX=128
selector_color=255,122,0,255
selector_text_color=255,255,255
defaultActionWhenCancel=1
[item]
text=PAUSE MENU
hPaddingDown=7
selectable=false
[/item]
[item]
text=CONTINUE
hPaddingDown=2
[/item]
[item]
text=LEAVE GAME
[/item]

View File

@@ -1,40 +0,0 @@
font_png=smb2.png
font_txt=smb2.txt
sound_move=menu_move.wav
sound_accept=menu_select.wav
name=PLAYER_SELECT
x=0
y=116
backgroundType=0
backgroundColor=48,48,64,192
areElementsCenteredOnX=true
isCenteredOnX=true
centerX=128
selector_color=255,122,0,255
selector_text_color=127,61,0,255
defaultActionWhenCancel=3
[item]
text=SELECT PLAYER
hPaddingDown=7
selectable=false
[/item]
[item]
text=BAL1
hPaddingDown=2
[/item]
[item]
text=AROUNDER
hPaddingDown=7
[/item]
[item]
text=BACK
[/item]

View File

@@ -57,8 +57,6 @@ const int GAMECANVAS_THIRD_QUARTER_Y = (HEIGHT / 4) * 3;
// Subsecciones // Subsecciones
#define SUBSECTION_GAME_PLAY_1P 0 #define SUBSECTION_GAME_PLAY_1P 0
#define SUBSECTION_GAME_PLAY_2P 1 #define SUBSECTION_GAME_PLAY_2P 1
#define SUBSECTION_GAME_PAUSE 2
#define SUBSECTION_GAME_GAMEOVER 3
#define SUBSECTION_TITLE_1 3 #define SUBSECTION_TITLE_1 3
#define SUBSECTION_TITLE_2 4 #define SUBSECTION_TITLE_2 4

View File

@@ -104,7 +104,7 @@ void Director::initInput()
// Teclado - Otros // Teclado - Otros
input->bindKey(input_accept, SDL_SCANCODE_RETURN); input->bindKey(input_accept, SDL_SCANCODE_RETURN);
input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE); input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
input->bindKey(input_pause, SDL_SCANCODE_ESCAPE); input->bindKey(input_pause, SDL_SCANCODE_P);
input->bindKey(input_exit, SDL_SCANCODE_ESCAPE); input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
input->bindKey(input_window_dec_size, SDL_SCANCODE_F1); input->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
input->bindKey(input_window_inc_size, SDL_SCANCODE_F2); input->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
@@ -121,7 +121,7 @@ void Director::initInput()
input->bindGameControllerButton(input_fire_right, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); input->bindGameControllerButton(input_fire_right, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
// Mando - Otros // Mando - Otros
input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B); input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_START);
input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A); input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START); input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START);
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK); input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
@@ -380,11 +380,6 @@ bool Director::setFileList()
asset->add(prefix + "/data/lang/en_UK.txt", t_lang); asset->add(prefix + "/data/lang/en_UK.txt", t_lang);
asset->add(prefix + "/data/lang/ba_BA.txt", t_lang); asset->add(prefix + "/data/lang/ba_BA.txt", t_lang);
// Menus
asset->add(prefix + "/data/menu/pause.men", t_data);
asset->add(prefix + "/data/menu/gameover.men", t_data);
asset->add(prefix + "/data/menu/player_select.men", t_data);
return asset->check(); return asset->check();
} }

View File

@@ -1,19 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "balloon.h"
#include "bullet.h"
#include "common/asset.h" #include "common/asset.h"
#include "common/input.h" #include "common/input.h"
#include "common/jail_audio.h" #include "common/jail_audio.h"
#include "common/menu.h"
#include "common/movingsprite.h"
#include "common/screen.h" #include "common/screen.h"
#include "common/smartsprite.h"
#include "common/sprite.h"
#include "common/text.h" #include "common/text.h"
#include "common/utils.h" #include "common/utils.h"
#include "common/writer.h"
#include "const.h" #include "const.h"
#include "fade.h" #include "fade.h"
#include "game.h" #include "game.h"

View File

@@ -135,8 +135,6 @@ Game::~Game()
delete textBig; delete textBig;
delete textNokia2; delete textNokia2;
delete textNokiaBig2; delete textNokiaBig2;
delete gameOverMenu;
delete pauseMenu;
delete fade; delete fade;
delete eventHandler; delete eventHandler;
delete n1000Sprite; delete n1000Sprite;
@@ -222,14 +220,11 @@ void Game::init()
break; break;
} }
// Colores
pauseMenu->setSelectorColor(difficultyColor, 255);
gameOverMenu->setSelectorColor(difficultyColor, 255);
// Variables para el marcador // Variables para el marcador
scoreboard->setPos({param->scoreboard.x, param->scoreboard.y, param->scoreboard.w, param->scoreboard.h}); scoreboard->setPos({param->scoreboard.x, param->scoreboard.y, param->scoreboard.w, param->scoreboard.h});
// Resto de variables // Resto de variables
paused = false;
gameCompleted = false; gameCompleted = false;
gameCompletedCounter = 0; gameCompletedCounter = 0;
section->name = SECTION_PROG_GAME; section->name = SECTION_PROG_GAME;
@@ -258,8 +253,6 @@ void Game::init()
powerBallEnabled = false; powerBallEnabled = false;
powerBallCounter = 0; powerBallCounter = 0;
coffeeMachineEnabled = false; coffeeMachineEnabled = false;
pauseCounter = 0;
leavingPauseMenu = false;
if (demo.enabled) if (demo.enabled)
{ {
@@ -502,18 +495,6 @@ void Game::loadMedia()
textNokia2 = new Text(asset->get("nokia2.png"), asset->get("nokia2.txt"), renderer); textNokia2 = new Text(asset->get("nokia2.png"), asset->get("nokia2.txt"), renderer);
textNokiaBig2 = new Text(asset->get("nokia_big2.png"), asset->get("nokia_big2.txt"), renderer); textNokiaBig2 = new Text(asset->get("nokia_big2.png"), asset->get("nokia_big2.txt"), renderer);
// Menus
gameOverMenu = new Menu(renderer, asset, input, asset->get("gameover.men"));
gameOverMenu->setItemCaption(0, lang->getText(48));
gameOverMenu->setItemCaption(1, lang->getText(49));
const int w = text->getCharacterSize() * lang->getText(45).length();
gameOverMenu->setRectSize(w, 0);
gameOverMenu->centerMenuOnX(199);
pauseMenu = new Menu(renderer, asset, input, asset->get("pause.men"));
pauseMenu->setItemCaption(0, lang->getText(41));
pauseMenu->setItemCaption(1, lang->getText(46));
pauseMenu->setItemCaption(2, lang->getText(47));
// Sonidos // Sonidos
balloonSound = JA_LoadSound(asset->get("balloon.wav").c_str()); balloonSound = JA_LoadSound(asset->get("balloon.wav").c_str());
bubble1Sound = JA_LoadSound(asset->get("bubble1.wav").c_str()); bubble1Sound = JA_LoadSound(asset->get("bubble1.wav").c_str());
@@ -1663,7 +1644,9 @@ void Game::updateDeath()
} }
else else
{ {
section->subsection = SUBSECTION_GAME_GAMEOVER; // section->subsection = SUBSECTION_GAME_GAMEOVER;
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
} }
} }
} }
@@ -2555,6 +2538,11 @@ void Game::updateEnemyDeployCounter()
// Actualiza el juego // Actualiza el juego
void Game::update() void Game::update()
{ {
if (paused)
{
return;
}
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
if (SDL_GetTicks() - ticks > ticksSpeed) if (SDL_GetTicks() - ticks > ticksSpeed)
{ {
@@ -2567,9 +2555,6 @@ void Game::update()
// Actualiza el objeto screen // Actualiza el objeto screen
screen->update(); screen->update();
// Comprueba el teclado/mando
checkGameInput();
// Actualiza las variables del jugador // Actualiza las variables del jugador
updatePlayers(); updatePlayers();
@@ -2751,8 +2736,18 @@ void Game::checkGameInput()
demo.keys.fireLeft = 0; demo.keys.fireLeft = 0;
demo.keys.fireRight = 0; demo.keys.fireRight = 0;
// Comprueba las teclas de cambiar el tamaño de la centana y el modo de video // Comprueba las teclas que afectan al programa (solo para el primer jugador)
if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_PROG_QUIT;
}
else if (input->checkInput(input_pause, REPEAT_FALSE))
{
paused = !paused;
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{ {
screen->switchVideoMode(); screen->switchVideoMode();
} }
@@ -2919,12 +2914,6 @@ void Game::checkGameInput()
} }
} }
// Comprueba el input de pausa
if (input->checkInput(input_cancel, REPEAT_FALSE, options->game.input[i].deviceType, options->game.input[i].id))
{
section->subsection = SUBSECTION_GAME_PAUSE;
}
if (demo.counter < TOTAL_DEMO_DATA) if (demo.counter < TOTAL_DEMO_DATA)
{ {
if (demo.recording) if (demo.recording)
@@ -3047,18 +3036,6 @@ void Game::run()
{ {
while (section->name == SECTION_PROG_GAME) while (section->name == SECTION_PROG_GAME)
{ {
// Sección juego en pausa
if (section->subsection == SUBSECTION_GAME_PAUSE)
{
runPausedGame();
}
// Sección Game Over
if (section->subsection == SUBSECTION_GAME_GAMEOVER)
{
runGameOverScreen();
}
// Sección juego jugando // Sección juego jugando
if ((section->subsection == SUBSECTION_GAME_PLAY_1P) || (section->subsection == SUBSECTION_GAME_PLAY_2P)) if ((section->subsection == SUBSECTION_GAME_PLAY_1P) || (section->subsection == SUBSECTION_GAME_PLAY_2P))
{ {
@@ -3075,6 +3052,9 @@ void Game::run()
} }
} }
// Comprueba el teclado/mando
checkGameInput();
// Actualiza la lógica del juego // Actualiza la lógica del juego
update(); update();
@@ -3087,302 +3067,6 @@ void Game::run()
} }
} }
// Actualiza las variables del menu de pausa del juego
void Game::updatePausedGame()
{
// Calcula la lógica de los objetos
if (SDL_GetTicks() - ticks > ticksSpeed)
{
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
if (leavingPauseMenu)
{
if (pauseCounter > 0)
{ // El contador está descendiendo
const bool a = pauseCounter == 90;
const bool b = pauseCounter == 60;
const bool c = pauseCounter == 30;
if (a || b || c)
{
JA_PlaySound(clockSound);
}
pauseCounter--;
}
else
{ // Ha finalizado el contador
section->name = SECTION_PROG_GAME;
section->subsection = numPlayers == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P;
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
{
JA_ResumeMusic();
}
}
}
else
{ // Actualiza la lógica del menu de pausa
pauseMenu->update();
// Comprueba las entradas para el menu
pauseMenu->checkInput();
// Comprueba si se ha seleccionado algún item del menú
switch (pauseMenu->getItemSelected())
{
case 1:
leavingPauseMenu = true;
break;
case 2:
fade->setType(FADE_CENTER);
fade->activate();
break;
default:
break;
}
// Actualiza el fade
fade->update();
if (fade->hasEnded())
{
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
JA_StopMusic();
}
}
}
}
// Dibuja el menu de pausa del juego
void Game::renderPausedGame()
{
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Limpia la pantalla
screen->clean(bgColor);
// Pinta el escenario
fillCanvas();
SDL_RenderCopy(renderer, canvas, nullptr, &playArea);
if ((deathCounter <= 150) && !players[0]->isAlive())
{
renderDeathFade(150 - deathCounter);
}
if ((gameCompleted) && (gameCompletedCounter >= GAME_COMPLETED_START_FADE))
{
renderDeathFade(gameCompletedCounter - GAME_COMPLETED_START_FADE);
}
if (leavingPauseMenu)
{
textNokiaBig2->writeCentered(GAMECANVAS_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, std::to_string((pauseCounter / 30) + 1));
}
else
{
pauseMenu->render();
}
fade->render();
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}
// Bucle para el menu de pausa del juego
void Game::runPausedGame()
{
// Pone en pausa la música
if (JA_GetMusicState() == JA_MUSIC_PLAYING)
{
JA_PauseMusic();
}
// Reinicia el menu
pauseMenu->reset();
leavingPauseMenu = false;
// Inicializa variables
pauseCounter = 90;
while ((section->subsection == SUBSECTION_GAME_PAUSE) && (section->name == SECTION_PROG_GAME))
{
updatePausedGame();
checkEvents();
renderPausedGame();
}
}
// Actualiza los elementos de la pantalla de game over
void Game::updateGameOverScreen()
{
// Variables
static int postFade = 0;
// Calcula la lógica de los objetos
if (SDL_GetTicks() - ticks > ticksSpeed)
{
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Actualiza la lógica del menu
gameOverMenu->update();
// Actualiza el fade
fade->update();
// Si ha terminado el fade, actua segun se haya operado
if (fade->hasEnded())
{
switch (postFade)
{
case 0: // YES
section->name = SECTION_PROG_GAME;
deleteAllVectorObjects();
init();
section->subsection = numPlayers == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P;
break;
case 1: // NO
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
break;
default:
break;
}
}
// Comprueba las entradas para el menu solo si no esta el juego completo
if (!gameCompleted)
{
gameOverMenu->checkInput();
// Comprueba si se ha seleccionado algún item del menú
switch (gameOverMenu->getItemSelected())
{
case 0: // YES
postFade = 0;
fade->activate();
break;
case 1: // NO
postFade = 1;
fade->activate();
break;
default:
break;
}
}
}
// 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;
break;
}
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
{
if (gameCompleted)
{
postFade = 1;
fade->activate();
JA_PlaySound(itemPickUpSound);
}
}
}
}
// Dibuja los elementos de la pantalla de game over
void Game::renderGameOverScreen()
{
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Limpia la pantalla
screen->clean(bgColor);
// Dibujo
if (!gameCompleted)
{ // Dibujo de haber perdido la partida
gameOverSprite->render();
}
else
{ // Dinujo de haber completado la partida
gameOverEndSprite->render();
}
// Dibuja los objetos
if (numPlayers == 1)
{
// Congratulations!!
if (gameCompleted)
{
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 8), lang->getText(50));
}
// Game Over
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), lang->getText(43));
// Your Score
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 3), lang->getText(44) + std::to_string(players[0]->getScore()));
}
else
{
// Congratulations!!
if (gameCompleted)
{
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 9), lang->getText(50));
}
// Game Over
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 7), lang->getText(43));
// Player1 Score
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), lang->getText(77) + std::to_string(players[0]->getScore()));
// Player2 Score
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 2), lang->getText(78) + std::to_string(players[1]->getScore()));
}
// Continue?
if (!gameCompleted)
{ // Solo dibuja el menu de continuar en el caso de no haber completado la partida
text->writeCentered(199, PLAY_AREA_CENTER_Y + BLOCK * 3, lang->getText(45));
gameOverMenu->render();
}
// Pinta el fade
fade->render();
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}
// Bucle para la pantalla de game over
void Game::runGameOverScreen()
{
// Guarda los puntos
saveScoreFile();
// Reinicia el menu
gameOverMenu->reset();
while ((section->subsection == SUBSECTION_GAME_GAMEOVER) && (section->name == SECTION_PROG_GAME))
{
updateGameOverScreen();
renderGameOverScreen();
}
}
// Indica si se puede crear una powerball // Indica si se puede crear una powerball
bool Game::canPowerBallBeCreated() bool Game::canPowerBallBeCreated()
{ {
@@ -3489,7 +3173,9 @@ void Game::updateGameCompleted()
if (gameCompletedCounter == GAME_COMPLETED_END) if (gameCompletedCounter == GAME_COMPLETED_END)
{ {
section->subsection = SUBSECTION_GAME_GAMEOVER; // section->subsection = SUBSECTION_GAME_GAMEOVER;
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
} }
} }
@@ -3555,7 +3241,12 @@ void Game::checkEvents()
{ {
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST) if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
{ {
section->subsection = SUBSECTION_GAME_PAUSE; paused = true;
}
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
{
paused = false;
} }
} }
} }

View File

@@ -6,14 +6,12 @@
#include "common/asset.h" #include "common/asset.h"
#include "common/input.h" #include "common/input.h"
#include "common/jail_audio.h" #include "common/jail_audio.h"
#include "common/menu.h"
#include "common/movingsprite.h" #include "common/movingsprite.h"
#include "common/screen.h" #include "common/screen.h"
#include "common/smartsprite.h" #include "common/smartsprite.h"
#include "common/sprite.h" #include "common/sprite.h"
#include "common/text.h" #include "common/text.h"
#include "common/utils.h" #include "common/utils.h"
#include "common/writer.h"
#include "const.h" #include "const.h"
#include "fade.h" #include "fade.h"
#include "item.h" #include "item.h"
@@ -147,9 +145,6 @@ private:
Text *textNokia2; // Otra fuente de texto para mensajes Text *textNokia2; // Otra fuente de texto para mensajes
Text *textNokiaBig2; // Y la versión en grande Text *textNokiaBig2; // Y la versión en grande
Menu *gameOverMenu; // Menú de la pantalla de game over
Menu *pauseMenu; // Menú de la pantalla de pausa
Fade *fade; // Objeto para renderizar fades Fade *fade; // Objeto para renderizar fades
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
@@ -219,8 +214,7 @@ private:
Uint8 lastStageReached; // Contiene el numero de la última pantalla que se ha alcanzado Uint8 lastStageReached; // Contiene el numero de la última pantalla que se ha alcanzado
demo_t demo; // Variable con todas las variables relacionadas con el modo demo demo_t demo; // Variable con todas las variables relacionadas con el modo demo
int totalPowerToCompleteGame; // La suma del poder necesario para completar todas las fases int totalPowerToCompleteGame; // La suma del poder necesario para completar todas las fases
int pauseCounter; // Contador para salir del menu de pausa y volver al juego bool paused; // Indica si el juego está pausado (no se deberia de poder utilizar en el modo arcade)
bool leavingPauseMenu; // Indica si esta saliendo del menu de pausa para volver al juego
// Actualiza el juego // Actualiza el juego
void update(); void update();
@@ -429,24 +423,12 @@ private:
// Deshabilita el efecto del item de detener el tiempo // Deshabilita el efecto del item de detener el tiempo
void disableTimeStopItem(); void disableTimeStopItem();
// Actualiza las variables del menu de pausa del juego
void updatePausedGame();
// Dibuja el menu de pausa del juego
void renderPausedGame();
// Bucle para el menu de pausa del juego
void runPausedGame();
// Actualiza los elementos de la pantalla de game over // Actualiza los elementos de la pantalla de game over
void updateGameOverScreen(); void updateGameOverScreen();
// Dibuja los elementos de la pantalla de game over // Dibuja los elementos de la pantalla de game over
void renderGameOverScreen(); void renderGameOverScreen();
// Bucle para la pantalla de game over
void runGameOverScreen();
// Indica si se puede crear una powerball // Indica si se puede crear una powerball
bool canPowerBallBeCreated(); bool canPowerBallBeCreated();

View File

@@ -2,16 +2,10 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/asset.h" #include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/menu.h"
#include "common/movingsprite.h"
#include "common/screen.h" #include "common/screen.h"
#include "common/smartsprite.h"
#include "common/sprite.h" #include "common/sprite.h"
#include "common/text.h" #include "common/text.h"
#include "common/utils.h" #include "common/utils.h"
#include "common/writer.h"
#include "const.h" #include "const.h"
#include "lang.h" #include "lang.h"

View File

@@ -77,6 +77,7 @@ void Title::init()
fade->setType(FADE_RANDOM_SQUARE); fade->setType(FADE_RANDOM_SQUARE);
fade->setPost(param->fadePostDuration); fade->setPost(param->fadePostDuration);
demo = true; demo = true;
numControllers = input->getNumControllers();
} }
// Actualiza las variables del objeto // Actualiza las variables del objeto
@@ -167,7 +168,7 @@ void Title::render()
// Dibuja el mosacico de fondo // Dibuja el mosacico de fondo
tiledbg->render(); tiledbg->render();
//backgroundObj->render(); // backgroundObj->render();
// Dinuja el logo con el título del juego // Dinuja el logo con el título del juego
gameLogo->render(); gameLogo->render();
@@ -220,12 +221,23 @@ void Title::checkEvents()
// Comprueba las entradas // Comprueba las entradas
void Title::checkInput() void Title::checkInput()
{ {
if (input->checkInput(input_exit, REPEAT_FALSE)) // Comprueba todos los controladores
for (int i = 0; i < numControllers; ++i)
{ {
section->name = SECTION_PROG_QUIT; if (input->checkInput(input_exit, REPEAT_FALSE, options->game.input[i].deviceType, options->game.input[i].id))
{
section->name = SECTION_PROG_QUIT;
}
else if (input->checkInput(input_accept, REPEAT_FALSE, options->game.input[i].deviceType, options->game.input[i].id))
{
fade->activate();
postFade = i;
}
} }
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) // Comprueba solo el teclado
if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{ {
screen->switchVideoMode(); screen->switchVideoMode();
} }
@@ -244,34 +256,6 @@ void Title::checkInput()
{ {
screen->switchShaders(); screen->switchShaders();
} }
else if (input->checkInput(input_accept, REPEAT_FALSE))
{
fade->activate();
postFade = 0;
postFade = 1;
}
}
// Cambia el valor de la variable de modo de pantalla completa
void Title::switchFullScreenModeVar()
{
switch (options->video.mode)
{
case 0:
options->video.mode = SDL_WINDOW_FULLSCREEN;
break;
case SDL_WINDOW_FULLSCREEN:
options->video.mode = SDL_WINDOW_FULLSCREEN_DESKTOP;
break;
case SDL_WINDOW_FULLSCREEN_DESKTOP:
options->video.mode = 0;
break;
default:
options->video.mode = 0;
break;
}
} }
// Bucle para el titulo del juego // Bucle para el titulo del juego

View File

@@ -4,7 +4,6 @@
#include "common/asset.h" #include "common/asset.h"
#include "common/input.h" #include "common/input.h"
#include "common/jail_audio.h" #include "common/jail_audio.h"
#include "common/menu.h"
#include "common/movingsprite.h" #include "common/movingsprite.h"
#include "common/screen.h" #include "common/screen.h"
#include "common/smartsprite.h" #include "common/smartsprite.h"
@@ -33,18 +32,18 @@ class Title
{ {
private: private:
// Objetos y punteros // Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla Screen *screen; // Objeto encargado de dibujar en pantalla
Asset *asset; // Objeto que gestiona todos los ficheros de recursos Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Objeto para leer las entradas de teclado o mando Input *input; // Objeto para leer las entradas de teclado o mando
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
section_t *section; // Indicador para el bucle del titulo section_t *section; // Indicador para el bucle del titulo
Background *backgroundObj; // Objeto para dibujar el fondo del juego Background *backgroundObj; // Objeto para dibujar el fondo del juego
Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo
GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego
Texture *miniLogoTexture; // Textura con el logo de JailGames mini Texture *miniLogoTexture; // Textura con el logo de JailGames mini
Sprite *miniLogoSprite; // Sprite con el logo de JailGames mini Sprite *miniLogoSprite; // Sprite con el logo de JailGames mini
Text *text1; // Objeto de texto para poder escribir textos en pantalla Text *text1; // Objeto de texto para poder escribir textos en pantalla
Text *text2; // Objeto de texto para poder escribir textos en pantalla Text *text2; // Objeto de texto para poder escribir textos en pantalla
@@ -53,14 +52,15 @@ private:
JA_Music_t *titleMusic; // Musica para el titulo JA_Music_t *titleMusic; // Musica para el titulo
// Variable // Variable
int counter; // Temporizador para la pantalla de titulo int counter; // Temporizador para la pantalla de titulo
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
bool demo; // Indica si el modo demo estará activo bool demo; // Indica si el modo demo estará activo
section_t nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo section_t nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
Uint8 postFade; // Opción a realizar cuando termina el fundido Uint8 postFade; // Opción a realizar cuando termina el fundido
options_t *options; // Variable con todas las variables de las opciones del programa options_t *options; // Variable con todas las variables de las opciones del programa
param_t *param; // Puntero con todos los parametros del programa param_t *param; // Puntero con todos los parametros del programa
int numControllers; // Número de mandos conectados
// Inicializa los valores de las variables // Inicializa los valores de las variables
void init(); void init();
@@ -77,9 +77,6 @@ private:
// Comprueba las entradas // Comprueba las entradas
void checkInput(); void checkInput();
// Cambia el valor de la variable de modo de pantalla completa
void switchFullScreenModeVar();
// Recarga las texturas // Recarga las texturas
void reLoadTextures(); void reLoadTextures();