Añadido un define para poder pausar el juego y hacer capturas de pantalla

This commit is contained in:
2024-08-03 10:03:43 +02:00
parent ff7170934e
commit ea5c2c15d6
3 changed files with 26 additions and 1 deletions

View File

@@ -19,7 +19,7 @@ windows:
windows_debug: windows_debug:
@echo off @echo off
g++ $(source) -D DEBUG -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable)_debug.exe" g++ $(source) -D DEBUG -D PAUSE -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable)_debug.exe"
strip -s -R .comment -R .gnu.version "$(executable)_debug.exe" --strip-unneeded strip -s -R .comment -R .gnu.version "$(executable)_debug.exe" --strip-unneeded
windows_release: windows_release:

View File

@@ -16,7 +16,11 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
// Pasa variables // Pasa variables
this->demo.enabled = demo; this->demo.enabled = demo;
this->numPlayers = numPlayers; this->numPlayers = numPlayers;
#ifdef PAUSE
this->currentStage = 3;
#else
this->currentStage = currentStage; this->currentStage = currentStage;
#endif
lastStageReached = currentStage; lastStageReached = currentStage;
if (numPlayers == 1) if (numPlayers == 1)
{ // Si solo juega un jugador, permite jugar tanto con teclado como con mando { // Si solo juega un jugador, permite jugar tanto con teclado como con mando
@@ -57,6 +61,9 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
// Inicializa las variables necesarias para la sección 'Game' // Inicializa las variables necesarias para la sección 'Game'
init(); init();
#ifdef PAUSE
pause = false;
#endif
} }
Game::~Game() Game::~Game()
@@ -3367,8 +3374,13 @@ void Game::run()
} }
} }
#ifdef PAUSE
if (!pause)
update();
#else
// Actualiza la lógica del juego // Actualiza la lógica del juego
update(); update();
#endif
// Comprueba los eventos que hay en cola // Comprueba los eventos que hay en cola
checkEvents(); checkEvents();
@@ -3869,6 +3881,16 @@ void Game::checkEvents()
section->subsection = SUBSECTION_GAME_PAUSE; section->subsection = SUBSECTION_GAME_PAUSE;
} }
} }
#ifdef PAUSE
else if (eventHandler->type == SDL_KEYDOWN)
{
if (eventHandler->key.keysym.scancode == SDL_SCANCODE_P)
{
pause = !pause;
}
}
#endif
} }
} }

View File

@@ -238,6 +238,9 @@ private:
int cloudsSpeed; // Velocidad a la que se desplazan las nubes int cloudsSpeed; // Velocidad a la que se desplazan las nubes
int pauseCounter; // Contador para salir del menu de pausa y volver al juego int pauseCounter; // Contador para salir del menu de pausa y volver al juego
bool leavingPauseMenu; // Indica si esta saliendo del menu de pausa para volver al juego bool leavingPauseMenu; // Indica si esta saliendo del menu de pausa para volver al juego
#ifdef PAUSE
bool pause;
#endif
// Actualiza el juego // Actualiza el juego
void update(); void update();