Añadida opción para intercambiar los jugadores de los dos primeros mandos
This commit is contained in:
@@ -69,7 +69,7 @@ void DefineButtons::render()
|
|||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
text->writeCentered(x, y - 10, "JUGADOR " + std::to_string(indexController + 1));
|
text->writeCentered(x, y - 10, "JUGADOR " + std::to_string(options->controller[indexController].playerId));
|
||||||
text->writeCentered(x, y, controllerNames[indexController]);
|
text->writeCentered(x, y, controllerNames[indexController]);
|
||||||
text->writeCentered(x, y + 10, buttons[indexButton].label);
|
text->writeCentered(x, y + 10, buttons[indexButton].label);
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,9 @@ void DefineButtons::checkInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == SDL_CONTROLLERBUTTONDOWN)
|
if (event.type == SDL_CONTROLLERBUTTONDOWN)
|
||||||
|
{
|
||||||
doControllerButtonDown(&event.cbutton);
|
doControllerButtonDown(&event.cbutton);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,3 +174,11 @@ void DefineButtons::saveBindingsToOptions()
|
|||||||
options->controller[indexController].buttons[j] = input->getControllerBinding(indexController, options->controller[indexController].inputs[j]);
|
options->controller[indexController].buttons[j] = input->getControllerBinding(indexController, options->controller[indexController].inputs[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Intercambia los jugadores asignados a los dos primeros mandos
|
||||||
|
void DefineButtons::swapControllers()
|
||||||
|
{
|
||||||
|
const int temp = options->controller[0].playerId;
|
||||||
|
options->controller[0].playerId = options->controller[1].playerId;
|
||||||
|
options->controller[1].playerId = temp;
|
||||||
|
}
|
||||||
@@ -65,4 +65,7 @@ public:
|
|||||||
|
|
||||||
// Comprueba si está habilitado
|
// Comprueba si está habilitado
|
||||||
bool isEnabled();
|
bool isEnabled();
|
||||||
|
|
||||||
|
// Intercambia los jugadores asignados a los dos primeros mandos
|
||||||
|
void swapControllers();
|
||||||
};
|
};
|
||||||
@@ -877,7 +877,7 @@ void Director::runTitle()
|
|||||||
// Ejecuta la sección donde se juega al juego
|
// Ejecuta la sección donde se juega al juego
|
||||||
void Director::runGame()
|
void Director::runGame()
|
||||||
{
|
{
|
||||||
const int playerID = section->options == SECTION_OPTIONS_GAME_PLAY_1P ? 0 : 1;
|
const int playerID = section->options;
|
||||||
game = new Game(playerID, 0, screen, asset, lang, input, false, param, options, section, getMusic(musics, "playing.ogg"));
|
game = new Game(playerID, 0, screen, asset, lang, input, false, param, options, section, getMusic(musics, "playing.ogg"));
|
||||||
game->run();
|
game->run();
|
||||||
delete game;
|
delete game;
|
||||||
|
|||||||
@@ -122,11 +122,14 @@ void Game::init(int playerID)
|
|||||||
player2->setController(controller2);
|
player2->setController(controller2);
|
||||||
players.push_back(player2);
|
players.push_back(player2);
|
||||||
|
|
||||||
|
// Obtiene el "id" del jugador que va a jugar
|
||||||
|
Player *player = getPlayer(playerID);
|
||||||
|
|
||||||
// Cambia el estado del jugador seleccionado
|
// Cambia el estado del jugador seleccionado
|
||||||
players[playerID]->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
player->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
||||||
|
|
||||||
// Como es el principio del juego, empieza sin inmunidad
|
// Como es el principio del juego, empieza sin inmunidad
|
||||||
players[playerID]->setInvulnerable(false);
|
player->setInvulnerable(false);
|
||||||
|
|
||||||
// Variables relacionadas con la dificultad
|
// Variables relacionadas con la dificultad
|
||||||
switch (difficulty)
|
switch (difficulty)
|
||||||
@@ -224,8 +227,9 @@ void Game::init(int playerID)
|
|||||||
// Activa o no al otro jugador
|
// Activa o no al otro jugador
|
||||||
if (rand() % 2 == 0)
|
if (rand() % 2 == 0)
|
||||||
{
|
{
|
||||||
const int otherPlayer = playerID == 1 ? 1 : 0;
|
const int otherPlayer = playerID == 1 ? 2 : 1;
|
||||||
players[otherPlayer]->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
Player *player = getPlayer(otherPlayer);
|
||||||
|
player->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto player : players)
|
for (auto player : players)
|
||||||
|
|||||||
@@ -91,26 +91,16 @@ void Title::update()
|
|||||||
fade->update();
|
fade->update();
|
||||||
if (fade->hasEnded())
|
if (fade->hasEnded())
|
||||||
{
|
{
|
||||||
switch (postFade)
|
if (postFade == -1)
|
||||||
{
|
{
|
||||||
case 1: // 1 PLAYER
|
|
||||||
section->name = SECTION_PROG_GAME;
|
|
||||||
section->options = SECTION_OPTIONS_GAME_PLAY_1P;
|
|
||||||
JA_StopMusic();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: // 2 PLAYER
|
|
||||||
section->name = SECTION_PROG_GAME;
|
|
||||||
section->options = SECTION_OPTIONS_GAME_PLAY_2P;
|
|
||||||
JA_StopMusic();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: // TIME OUT
|
|
||||||
section->name = SECTION_PROG_GAME_DEMO;
|
section->name = SECTION_PROG_GAME_DEMO;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
}
|
||||||
break;
|
else
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_GAME;
|
||||||
|
section->options = postFade;
|
||||||
|
JA_StopMusic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +138,7 @@ void Title::update()
|
|||||||
if (counter == param->title.titleDuration)
|
if (counter == param->title.titleDuration)
|
||||||
{
|
{
|
||||||
fade->activate();
|
fade->activate();
|
||||||
postFade = 3;
|
postFade = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,6 +210,28 @@ void Title::checkEvents()
|
|||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||||
|
{
|
||||||
|
switch (eventHandler->key.keysym.sym)
|
||||||
|
{
|
||||||
|
case SDLK_1:
|
||||||
|
defineButtons->enable(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_2:
|
||||||
|
defineButtons->enable(1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_3:
|
||||||
|
defineButtons->swapControllers();
|
||||||
|
screen->showNotification("Swap Controllers");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba en el primer mando el botón de salir del programa
|
// Comprueba en el primer mando el botón de salir del programa
|
||||||
// else if (eventHandler->type == SDL_CONTROLLERBUTTONDOWN)
|
// else if (eventHandler->type == SDL_CONTROLLERBUTTONDOWN)
|
||||||
//{
|
//{
|
||||||
@@ -257,22 +269,10 @@ void Title::checkInput()
|
|||||||
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||||
{
|
{
|
||||||
fade->activate();
|
fade->activate();
|
||||||
postFade = 1;
|
postFade = options->controller[0].playerId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si se ha pulsado la tecla 1 o 2 para definir los controladores
|
|
||||||
const Uint8 *keyStates = SDL_GetKeyboardState(nullptr);
|
|
||||||
|
|
||||||
if (keyStates[SDL_SCANCODE_1] != 0)
|
|
||||||
{
|
|
||||||
defineButtons->enable(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (keyStates[SDL_SCANCODE_2] != 0)
|
|
||||||
{
|
|
||||||
defineButtons->enable(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// MANDO //
|
// MANDO //
|
||||||
@@ -306,7 +306,7 @@ void Title::checkInput()
|
|||||||
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||||
{
|
{
|
||||||
fade->activate();
|
fade->activate();
|
||||||
postFade = i + 1;
|
postFade = options->controller[i].playerId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user