El responsable de comprobar si se ha pulsado alguna tecla para cambiar el tamaño de la venta, el modo de pantalla completa o la activación de los shaders pasa a ser la clase screen

This commit is contained in:
2024-07-05 14:09:38 +02:00
parent 5e7212dfaa
commit 62f3c42e7b
14 changed files with 209 additions and 187 deletions

View File

@@ -169,13 +169,11 @@ void Game::init(int playerID)
// Crea los jugadores
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[0], playerAnimations);
players.push_back(player1);
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[1], playerAnimations);
players.push_back(player2);
numPlayers = 2;
// Variables relacionadas con la dificultad
switch (difficulty)
@@ -1630,7 +1628,7 @@ void Game::updateDeath()
fade->activate();
}
}
if (fade->hasEnded())
{
// section->subsection = SUBSECTION_GAME_GAMEOVER;
@@ -2504,6 +2502,9 @@ void Game::update()
// Actualiza el contador de juego
counter++;
// Comprueba si la música ha de estar sonando
checkMusicStatus();
// Actualiza el objeto screen
screen->update();
@@ -2693,26 +2694,6 @@ void Game::checkGameInput()
pause(!paused);
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
else if (input->checkInput(input_video_shaders, REPEAT_FALSE))
{
screen->switchShaders();
}
// Modo Demo activo
if (demo.enabled)
{
@@ -2885,6 +2866,9 @@ void Game::checkGameInput()
}
}
}
// Comprueba el input para el resto de objetos
screen->checkInput();
}
// Pinta diferentes mensajes en la pantalla
@@ -2981,39 +2965,32 @@ void Game::disableTimeStopItem()
}
}
// Comprueba si la música ha de estar sonando
void Game::checkMusicStatus()
{
// Si la música no está sonando
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
// Reproduce la música
if (!gameCompleted)
{
if (players[0]->isAlive() || players[1]->isAlive())
{
JA_PlayMusic(music);
}
}
}
}
// Bucle para el juego
void Game::run()
{
while (section->name == SECTION_PROG_GAME)
{
// Sección juego jugando
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))
{
// Reproduce la música
if (!gameCompleted)
{
if (players[0]->isAlive())
{
JA_PlayMusic(music);
}
}
}
// Comprueba el teclado/mando
checkGameInput();
// Actualiza la lógica del juego
update();
// Comprueba los eventos que hay en cola
checkEvents();
// Dibuja los objetos
render();
}
checkGameInput();
update();
checkEvents(); // Tiene que ir antes del render
render();
}
}
@@ -3198,6 +3175,11 @@ void Game::checkEvents()
{
pause(false);
}
if (eventHandler->window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{
reloadTextures();
}
}
}
}