Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d52c45f5c | |||
| 3276027044 | |||
| 8041595976 | |||
| fa53c1b01a | |||
| 20b362160e | |||
| 5cabbfc487 | |||
| 9f5e001c70 | |||
| 112c3afc76 | |||
| f4215384fe | |||
| 7796cee51a |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,6 +1,6 @@
|
|||||||
.vscode
|
.vscode
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
bin
|
bin
|
||||||
data/config.txt
|
data/config/config.txt
|
||||||
data/config.bin
|
data/config/config.bin
|
||||||
data/score.bin
|
data/config/score.bin
|
||||||
5
Makefile
5
Makefile
@@ -3,10 +3,11 @@ executable = coffee_crisis
|
|||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
if not exist bin\ (mkdir bin)
|
if not exist bin\ (mkdir bin)
|
||||||
g++ -std=c++11 -Wall -O2 source/*.cpp -lmingw32 -lSDL2main -lSDL2 -o bin/$(executable).exe
|
g++ -std=c++11 -Wall -O2 source/*.cpp -lmingw32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -o bin/$(executable).exe
|
||||||
|
strip -s -R .comment -R .gnu.version bin/$(executable).exe --strip-unneeded
|
||||||
macos:
|
macos:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -o bin/$(executable)_macos
|
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -ffunction-sections -fdata-sections -o bin/$(executable)_macos
|
||||||
linux:
|
linux:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
g++ source/*.cpp -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o bin/$(executable)_linux
|
g++ source/*.cpp -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o bin/$(executable)_linux
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
115
source/game.cpp
115
source/game.cpp
@@ -273,6 +273,8 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -3073,11 +3075,6 @@ void Game::checkGameInput()
|
|||||||
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
||||||
{
|
{
|
||||||
section.subsection = GAME_SECTION_PAUSE;
|
section.subsection = GAME_SECTION_PAUSE;
|
||||||
|
|
||||||
if (JA_GetMusicState() == JA_MUSIC_PLAYING)
|
|
||||||
{
|
|
||||||
JA_PauseMusic();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demo.counter < TOTAL_DEMO_DATA)
|
if (demo.counter < TOTAL_DEMO_DATA)
|
||||||
@@ -3289,41 +3286,61 @@ void Game::updatePausedGame()
|
|||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Actualiza la lógica del menu de pausa
|
if (leavingPauseMenu)
|
||||||
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:
|
if (pauseCounter > 0)
|
||||||
section.name = PROG_SECTION_GAME;
|
{ // El contador está descendiendo
|
||||||
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
const bool a = pauseCounter == 90;
|
||||||
|
const bool b = pauseCounter == 60;
|
||||||
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
|
const bool c = pauseCounter == 30;
|
||||||
{
|
if (a || b || c)
|
||||||
JA_ResumeMusic();
|
{
|
||||||
|
JA_PlaySound(clockSound);
|
||||||
|
}
|
||||||
|
pauseCounter--;
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
|
{ // Ha finalizado el contador
|
||||||
|
section.name = PROG_SECTION_GAME;
|
||||||
|
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
||||||
|
|
||||||
case 2:
|
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
|
||||||
fade->setFadeType(FADE_CENTER);
|
{
|
||||||
fade->activateFade();
|
JA_ResumeMusic();
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{ // Actualiza la lógica del menu de pausa
|
||||||
|
pauseMenu->update();
|
||||||
|
|
||||||
// Actualiza el fade
|
// Comprueba las entradas para el menu
|
||||||
fade->update();
|
pauseMenu->checkInput();
|
||||||
if (fade->hasEnded())
|
|
||||||
{
|
// Comprueba si se ha seleccionado algún item del menú
|
||||||
section.name = PROG_SECTION_TITLE;
|
switch (pauseMenu->getItemSelected())
|
||||||
section.subsection = TITLE_SECTION_1;
|
{
|
||||||
JA_StopMusic();
|
case 1:
|
||||||
|
leavingPauseMenu = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
fade->setFadeType(FADE_CENTER);
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza el fade
|
||||||
|
fade->update();
|
||||||
|
if (fade->hasEnded())
|
||||||
|
{
|
||||||
|
section.name = PROG_SECTION_TITLE;
|
||||||
|
section.subsection = TITLE_SECTION_1;
|
||||||
|
JA_StopMusic();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3361,7 +3378,14 @@ void Game::renderPausedGame()
|
|||||||
renderFlashEffect();
|
renderFlashEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
pauseMenu->render();
|
if (leavingPauseMenu)
|
||||||
|
{
|
||||||
|
textNokiaBig2->writeCentered(SCREEN_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, std::to_string((pauseCounter / 30) + 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pauseMenu->render();
|
||||||
|
}
|
||||||
fade->render();
|
fade->render();
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
@@ -3371,8 +3395,18 @@ void Game::renderPausedGame()
|
|||||||
// Bucle para el menu de pausa del juego
|
// Bucle para el menu de pausa del juego
|
||||||
void Game::runPausedGame()
|
void Game::runPausedGame()
|
||||||
{
|
{
|
||||||
|
// Pone en pausa la música
|
||||||
|
if (JA_GetMusicState() == JA_MUSIC_PLAYING)
|
||||||
|
{
|
||||||
|
JA_PauseMusic();
|
||||||
|
}
|
||||||
|
|
||||||
// Reinicia el menu
|
// Reinicia el menu
|
||||||
pauseMenu->reset();
|
pauseMenu->reset();
|
||||||
|
leavingPauseMenu = false;
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
pauseCounter = 90;
|
||||||
|
|
||||||
while ((section.subsection == GAME_SECTION_PAUSE) && (section.name == PROG_SECTION_GAME))
|
while ((section.subsection == GAME_SECTION_PAUSE) && (section.name == PROG_SECTION_GAME))
|
||||||
{
|
{
|
||||||
@@ -3715,6 +3749,15 @@ void Game::checkEventHandler()
|
|||||||
section.name = PROG_SECTION_QUIT;
|
section.name = PROG_SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (eventHandler->type == SDL_WINDOWEVENT)
|
||||||
|
{
|
||||||
|
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||||
|
{
|
||||||
|
section.subsection = GAME_SECTION_PAUSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
|
|||||||
@@ -193,10 +193,9 @@ private:
|
|||||||
JA_Music gameMusic; // Musica de fondo
|
JA_Music gameMusic; // Musica de fondo
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int numPlayers; // Numero de jugadores
|
int numPlayers; // Numero de jugadores
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint8 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint8 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
|
|
||||||
Uint32 hiScore; // Puntuación máxima
|
Uint32 hiScore; // Puntuación máxima
|
||||||
bool hiScoreAchieved; // Indica si se ha superado la puntuación máxima
|
bool hiScoreAchieved; // Indica si se ha superado la puntuación máxima
|
||||||
section_t section; // Seccion actual dentro del juego
|
section_t section; // Seccion actual dentro del juego
|
||||||
@@ -236,6 +235,8 @@ private:
|
|||||||
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 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
|
||||||
|
bool leavingPauseMenu; // Indica si esta saliendo del menu de pausa para volver al juego
|
||||||
|
|
||||||
// Actualiza el juego
|
// Actualiza el juego
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ void Instructions::checkEventHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para la pantalla de instrucciones
|
// Bucle para la pantalla de instrucciones
|
||||||
void Instructions::run(mode_e mode)
|
section_t Instructions::run(mode_e mode)
|
||||||
{
|
{
|
||||||
this->mode = mode;
|
this->mode = mode;
|
||||||
|
|
||||||
@@ -245,4 +245,6 @@ void Instructions::run(mode_e mode)
|
|||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return section;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
~Instructions();
|
~Instructions();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
void run(mode_e mode);
|
section_t run(mode_e mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -301,7 +301,10 @@ void Title::update()
|
|||||||
if (demo)
|
if (demo)
|
||||||
{
|
{
|
||||||
runDemoGame();
|
runDemoGame();
|
||||||
runInstructions(m_auto);
|
if (section.name != PROG_SECTION_QUIT)
|
||||||
|
{
|
||||||
|
runInstructions(m_auto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
section.name = PROG_SECTION_LOGO;
|
section.name = PROG_SECTION_LOGO;
|
||||||
@@ -483,7 +486,10 @@ void Title::update()
|
|||||||
if (demo)
|
if (demo)
|
||||||
{
|
{
|
||||||
runDemoGame();
|
runDemoGame();
|
||||||
runInstructions(m_auto);
|
if (section.name != PROG_SECTION_QUIT)
|
||||||
|
{
|
||||||
|
runInstructions(m_auto);
|
||||||
|
}
|
||||||
init();
|
init();
|
||||||
demo = false;
|
demo = false;
|
||||||
counter = TITLE_COUNTER;
|
counter = TITLE_COUNTER;
|
||||||
@@ -939,19 +945,23 @@ section_t Title::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la parte donde se muestran las instrucciones
|
// Ejecuta la parte donde se muestran las instrucciones
|
||||||
void Title::runInstructions(mode_e mode)
|
section_t Title::runInstructions(mode_e mode)
|
||||||
{
|
{
|
||||||
instructions = new Instructions(renderer, screen, asset, lang);
|
instructions = new Instructions(renderer, screen, asset, lang);
|
||||||
instructions->run(mode);
|
section = instructions->run(mode);
|
||||||
delete instructions;
|
delete instructions;
|
||||||
|
|
||||||
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta el juego en modo demo
|
// Ejecuta el juego en modo demo
|
||||||
void Title::runDemoGame()
|
section_t Title::runDemoGame()
|
||||||
{
|
{
|
||||||
demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, options);
|
demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, options);
|
||||||
demoGame->run();
|
section = demoGame->run();
|
||||||
delete demoGame;
|
delete demoGame;
|
||||||
|
|
||||||
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifica las opciones para los controles de los jugadores
|
// Modifica las opciones para los controles de los jugadores
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#define TITLE_H
|
#define TITLE_H
|
||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
#define TEXT_COPYRIGHT "@2020,2022 JailDesigner (v2.1)"
|
#define TEXT_COPYRIGHT "@2020,2022 JailDesigner (v2.1a)"
|
||||||
|
|
||||||
// Contadores
|
// Contadores
|
||||||
#define TITLE_COUNTER 800
|
#define TITLE_COUNTER 800
|
||||||
@@ -117,10 +117,10 @@ private:
|
|||||||
void applyOptions();
|
void applyOptions();
|
||||||
|
|
||||||
// Ejecuta la parte donde se muestran las instrucciones
|
// Ejecuta la parte donde se muestran las instrucciones
|
||||||
void runInstructions(mode_e mode);
|
section_t runInstructions(mode_e mode);
|
||||||
|
|
||||||
// Ejecuta el juego en modo demo
|
// Ejecuta el juego en modo demo
|
||||||
void runDemoGame();
|
section_t runDemoGame();
|
||||||
|
|
||||||
// Modifica las opciones para los controles de los jugadores
|
// Modifica las opciones para los controles de los jugadores
|
||||||
bool updatePlayerInputs(int numPlayer);
|
bool updatePlayerInputs(int numPlayer);
|
||||||
|
|||||||
Reference in New Issue
Block a user