Compare commits
3 Commits
7e1085ea42
...
83fb2f30ba
| Author | SHA1 | Date | |
|---|---|---|---|
| 83fb2f30ba | |||
| 922d146781 | |||
| 1b2d1c5786 |
@@ -328,8 +328,6 @@ void Screen::checkInput()
|
||||
else if (input->checkInput(input_video_shaders, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
switchShaders();
|
||||
const std::string value = options->video.shaders ? "on" : "off";
|
||||
showNotification("Shaders " + value);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -419,6 +417,8 @@ void Screen::switchShaders()
|
||||
{
|
||||
options->video.shaders = !options->video.shaders;
|
||||
setVideoMode(options->video.mode);
|
||||
const std::string value = options->video.shaders ? "on" : "off";
|
||||
showNotification("Shaders " + value);
|
||||
}
|
||||
|
||||
// Atenua la pantalla
|
||||
|
||||
@@ -66,7 +66,7 @@ enum not_pos_e
|
||||
struct section_t
|
||||
{
|
||||
Uint8 name;
|
||||
Uint8 subsection;
|
||||
Uint8 options;
|
||||
};
|
||||
|
||||
// Estructura para las entradas de la tabla de recirds
|
||||
|
||||
@@ -21,10 +21,12 @@
|
||||
#define SECTION_PROG_QUIT 7
|
||||
|
||||
// Subsecciones
|
||||
#define SUBSECTION_GAME_PLAY_1P 0
|
||||
#define SUBSECTION_GAME_PLAY_2P 1
|
||||
#define SUBSECTION_TITLE_1 3
|
||||
#define SUBSECTION_TITLE_2 4
|
||||
#define SECTION_OPTIONS_GAME_PLAY_1P 0
|
||||
#define SECTION_OPTIONS_GAME_PLAY_2P 1
|
||||
#define SECTION_OPTIONS_TITLE_1 3
|
||||
#define SECTION_OPTIONS_TITLE_2 4
|
||||
#define SECTION_OPTIONS_QUIT_NORMAL 5
|
||||
#define SECTION_OPTIONS_QUIT_SHUTDOWN 6
|
||||
|
||||
// Ningun tipo
|
||||
#define NO_KIND 0
|
||||
|
||||
@@ -20,17 +20,17 @@ DefineButtons::DefineButtons(Input *input, Text *text, param_t *param, options_t
|
||||
buttons.clear();
|
||||
db_button_t button;
|
||||
|
||||
button.label = "DISPARO IZQUIERDA";
|
||||
button.label = "DISPARAR CAP A L'ESQUERRA";
|
||||
button.input = input_fire_left;
|
||||
button.button = SDL_CONTROLLER_BUTTON_X;
|
||||
buttons.push_back(button);
|
||||
|
||||
button.label = "DISPARO CENTRO";
|
||||
button.label = "DISPARAR CAP AMUNT";
|
||||
button.input = input_fire_center;
|
||||
button.button = SDL_CONTROLLER_BUTTON_Y;
|
||||
buttons.push_back(button);
|
||||
|
||||
button.label = "DISPARO DERECHA";
|
||||
button.label = "DISPARAR CAP A LA DRETA";
|
||||
button.input = input_fire_right;
|
||||
button.button = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER;
|
||||
buttons.push_back(button);
|
||||
@@ -40,7 +40,7 @@ DefineButtons::DefineButtons(Input *input, Text *text, param_t *param, options_t
|
||||
button.button = SDL_CONTROLLER_BUTTON_START;
|
||||
buttons.push_back(button);
|
||||
|
||||
button.label = "SALIR DEL JUEGO";
|
||||
button.label = "SERVEI";
|
||||
button.input = input_exit;
|
||||
button.button = SDL_CONTROLLER_BUTTON_BACK;
|
||||
buttons.push_back(button);
|
||||
@@ -69,7 +69,7 @@ void DefineButtons::render()
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
text->writeCentered(x, y - 10, "PLAYER " + std::to_string(indexController + 1));
|
||||
text->writeCentered(x, y - 10, "JUGADOR " + std::to_string(indexController + 1));
|
||||
text->writeCentered(x, y, controllerNames[indexController]);
|
||||
text->writeCentered(x, y + 10, buttons[indexButton].label);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ Director::Director(int argc, char *argv[])
|
||||
section = new section_t();
|
||||
#ifdef RECORDING
|
||||
section->name = SECTION_PROG_GAME;
|
||||
section->subsection = SUBSECTION_GAME_PLAY_1P;
|
||||
section->options = SECTION_OPTIONS_GAME_PLAY_1P;
|
||||
#elif DEBUG
|
||||
section->name = SECTION_PROG_LOGO;
|
||||
#else
|
||||
@@ -849,7 +849,7 @@ void Director::runTitle()
|
||||
// Ejecuta la sección donde se juega al juego
|
||||
void Director::runGame()
|
||||
{
|
||||
const int playerID = section->subsection == SUBSECTION_GAME_PLAY_1P ? 0 : 1;
|
||||
const int playerID = section->options == SECTION_OPTIONS_GAME_PLAY_1P ? 0 : 1;
|
||||
game = new Game(playerID, 0, screen, asset, lang, input, false, param, options, section, getMusic(musics, "playing.ogg"));
|
||||
game->run();
|
||||
delete game;
|
||||
@@ -880,7 +880,7 @@ void Director::runDemoGame()
|
||||
delete demoGame;
|
||||
}
|
||||
|
||||
void Director::run()
|
||||
int Director::run()
|
||||
{
|
||||
// Bucle principal
|
||||
while (section->name != SECTION_PROG_QUIT)
|
||||
@@ -916,6 +916,9 @@ void Director::run()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const int returnCode = section->options == SECTION_OPTIONS_QUIT_NORMAL ? 0 : 1;
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
// Asigna variables a partir de dos cadenas
|
||||
|
||||
@@ -122,5 +122,5 @@ public:
|
||||
~Director();
|
||||
|
||||
// Bucle principal
|
||||
void run();
|
||||
int run();
|
||||
};
|
||||
@@ -171,7 +171,7 @@ void Game::init(int playerID)
|
||||
gameCompleted = false;
|
||||
gameCompletedCounter = 0;
|
||||
section->name = SECTION_PROG_GAME;
|
||||
section->subsection = SUBSECTION_GAME_PLAY_1P;
|
||||
section->options = SECTION_OPTIONS_GAME_PLAY_1P;
|
||||
currentPower = 0;
|
||||
menaceCurrent = 0;
|
||||
menaceThreshold = 0;
|
||||
@@ -2484,9 +2484,9 @@ void Game::updateGameCompleted()
|
||||
|
||||
if (gameCompletedCounter == GAME_COMPLETED_END)
|
||||
{
|
||||
// section->subsection = SUBSECTION_GAME_GAMEOVER;
|
||||
// section->options = SUBSECTION_GAME_GAMEOVER;
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->options = SECTION_OPTIONS_TITLE_1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ void HiScoreTable::checkInput()
|
||||
{
|
||||
JA_StopMusic();
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->options = SECTION_OPTIONS_TITLE_1;
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
|
||||
@@ -253,7 +253,7 @@ void Instructions::update()
|
||||
if (counter == counterEnd)
|
||||
{
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->options = SECTION_OPTIONS_TITLE_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ void Instructions::checkInput()
|
||||
{
|
||||
JA_StopMusic();
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->options = SECTION_OPTIONS_TITLE_1;
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
|
||||
@@ -20,7 +20,7 @@ Intro::Intro(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *pa
|
||||
|
||||
// Inicializa variables
|
||||
section->name = SECTION_PROG_INTRO;
|
||||
section->subsection = 0;
|
||||
section->options = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
scene = 1;
|
||||
@@ -202,7 +202,7 @@ void Intro::checkInput()
|
||||
{
|
||||
JA_StopMusic();
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->options = SECTION_OPTIONS_TITLE_1;
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
@@ -355,7 +355,7 @@ void Intro::updateScenes()
|
||||
texts[8]->setEnabled(false);
|
||||
JA_StopMusic();
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->options = SECTION_OPTIONS_TITLE_1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -111,7 +111,7 @@ void Logo::checkInput()
|
||||
else if (input->checkAnyButtonPressed())
|
||||
{
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->options = SECTION_OPTIONS_TITLE_1;
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
|
||||
@@ -18,12 +18,12 @@ int main(int argc, char *argv[])
|
||||
Director *director = new Director(argc, argv);
|
||||
|
||||
// Bucle principal
|
||||
director->run();
|
||||
const int exit = director->run();
|
||||
|
||||
// Destruye el objeto Director
|
||||
delete director;
|
||||
|
||||
std::cout << "\nGame end" << std::endl;
|
||||
|
||||
return 0;
|
||||
return exit;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
#include "service.h"
|
||||
|
||||
int checkServiceButton(Input *input)
|
||||
// Comprueba el botón de servicio del controlador "index"
|
||||
int checkServiceButton(Input *input, int index)
|
||||
{
|
||||
if (input->checkInput(input_service))
|
||||
if (input->checkInput(input_service, true, INPUT_USE_GAMECONTROLLER, index))
|
||||
{
|
||||
if (input->checkInput(input_start))
|
||||
if (input->checkInput(input_start, false, INPUT_USE_GAMECONTROLLER, index))
|
||||
{
|
||||
return SERVICE_EXIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_fire_left))
|
||||
else if (input->checkInput(input_fire_left, false, INPUT_USE_GAMECONTROLLER, index))
|
||||
{
|
||||
return SERVICE_CONFIG;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_fire_center))
|
||||
else if (input->checkInput(input_fire_center, false, INPUT_USE_GAMECONTROLLER, index))
|
||||
{
|
||||
return SERVICE_SHADERS;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_fire_right))
|
||||
else if (input->checkInput(input_fire_right, false, INPUT_USE_GAMECONTROLLER, index))
|
||||
{
|
||||
return SERVICE_PAUSE;
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
#define SERVICE_SHADERS 3
|
||||
#define SERVICE_PAUSE 4
|
||||
|
||||
// Comprueba el botón de servicio
|
||||
int checkServiceButton(Input *input);
|
||||
// Comprueba el botón de servicio del controlador "index"
|
||||
int checkServiceButton(Input *input, int index);
|
||||
@@ -59,7 +59,7 @@ Title::~Title()
|
||||
void Title::init()
|
||||
{
|
||||
// Inicializa variables
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section->options = SECTION_OPTIONS_TITLE_1;
|
||||
counter = 0;
|
||||
nextSection.name = SECTION_PROG_GAME;
|
||||
postFade = 0;
|
||||
@@ -95,13 +95,13 @@ void Title::update()
|
||||
{
|
||||
case 1: // 1 PLAYER
|
||||
section->name = SECTION_PROG_GAME;
|
||||
section->subsection = SUBSECTION_GAME_PLAY_1P;
|
||||
section->options = SECTION_OPTIONS_GAME_PLAY_1P;
|
||||
JA_StopMusic();
|
||||
break;
|
||||
|
||||
case 2: // 2 PLAYER
|
||||
section->name = SECTION_PROG_GAME;
|
||||
section->subsection = SUBSECTION_GAME_PLAY_2P;
|
||||
section->options = SECTION_OPTIONS_GAME_PLAY_2P;
|
||||
JA_StopMusic();
|
||||
break;
|
||||
|
||||
@@ -115,17 +115,17 @@ void Title::update()
|
||||
}
|
||||
|
||||
// Sección 1 - Titulo animandose
|
||||
if (section->subsection == SUBSECTION_TITLE_1)
|
||||
if (section->options == SECTION_OPTIONS_TITLE_1)
|
||||
{
|
||||
gameLogo->update();
|
||||
if (gameLogo->hasFinished())
|
||||
{
|
||||
section->subsection = SUBSECTION_TITLE_2;
|
||||
section->options = SECTION_OPTIONS_TITLE_2;
|
||||
}
|
||||
}
|
||||
|
||||
// Sección 2 - La pantalla con el titulo, el fondo animado y la música
|
||||
else if (section->subsection == SUBSECTION_TITLE_2)
|
||||
else if (section->options == SECTION_OPTIONS_TITLE_2)
|
||||
{
|
||||
// El contador solo sube si no estamos definiendo botones
|
||||
if (!defineButtons->isEnabled())
|
||||
@@ -169,7 +169,7 @@ void Title::render()
|
||||
// Dibuja el logo con el título del juego
|
||||
gameLogo->render();
|
||||
|
||||
if (section->subsection == SUBSECTION_TITLE_2)
|
||||
if (section->options == SECTION_OPTIONS_TITLE_2)
|
||||
{
|
||||
const color_t shadow = {0x14, 0x87, 0xc4};
|
||||
// 'PULSA 1P o 2P PARA JUGAR'
|
||||
@@ -221,15 +221,15 @@ void Title::checkEvents()
|
||||
}
|
||||
|
||||
// Comprueba en el primer mando el botón de salir del programa
|
||||
else if (eventHandler->type == SDL_CONTROLLERBUTTONDOWN)
|
||||
{
|
||||
if ((SDL_GameControllerButton)eventHandler->cbutton.which == 0)
|
||||
if ((SDL_GameControllerButton)eventHandler->cbutton.button == input->getControllerBinding(0, input_exit))
|
||||
{
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// else if (eventHandler->type == SDL_CONTROLLERBUTTONDOWN)
|
||||
//{
|
||||
// if ((SDL_GameControllerButton)eventHandler->cbutton.which == 0)
|
||||
// if ((SDL_GameControllerButton)eventHandler->cbutton.button == input->getControllerBinding(0, input_exit))
|
||||
// {
|
||||
// section->name = SECTION_PROG_QUIT;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,21 +240,15 @@ void Title::checkInput()
|
||||
// Comprueba los controladores solo si no se estan definiendo los botones
|
||||
if (!defineButtons->isEnabled())
|
||||
{
|
||||
// Comprueba si se ha pulsado algún botón para empezar a jugar
|
||||
const int index = input->checkAnyButtonPressed();
|
||||
if (index)
|
||||
{
|
||||
if (section->subsection == SUBSECTION_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
{ // No se puede empezar a jugar durante la animación del titulo a menos que se permita
|
||||
fade->activate();
|
||||
postFade = index;
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////
|
||||
// TECLADO //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
// Comprueba el teclado para salir
|
||||
if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
section->options = SECTION_OPTIONS_QUIT_NORMAL;
|
||||
}
|
||||
|
||||
// Comprueba si se ha pulsado la tecla 1 o 2 para definir los controladores
|
||||
@@ -269,6 +263,43 @@ void Title::checkInput()
|
||||
{
|
||||
defineButtons->enable(1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// MANDO //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
// Comprueba el botón de SERVICE
|
||||
switch (checkServiceButton(input, 0))
|
||||
{
|
||||
case SERVICE_EXIT:
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
section->options = SECTION_OPTIONS_QUIT_SHUTDOWN;
|
||||
break;
|
||||
|
||||
case SERVICE_SHADERS:
|
||||
screen->switchShaders();
|
||||
break;
|
||||
|
||||
case SERVICE_CONFIG:
|
||||
defineButtons->enable(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Comprueba el botón de START
|
||||
for (int i = 0; i < input->getNumControllers(); ++i)
|
||||
{
|
||||
if (input->checkInput(input_start, false, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
{
|
||||
fade->activate();
|
||||
postFade = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "tiledbg.h"
|
||||
#include "game_logo.h"
|
||||
#include "define_buttons.h"
|
||||
#include "service.h"
|
||||
|
||||
// Textos
|
||||
#define TEXT_COPYRIGHT "@2020,2024 JailDesigner"
|
||||
|
||||
Reference in New Issue
Block a user