Ya rueda por los diferentes estados del juego: logo, titulo, creditos, demo

This commit is contained in:
2022-10-13 12:36:34 +02:00
parent 3f3f50a583
commit 4d462e6564
8 changed files with 49 additions and 41 deletions

View File

@@ -3,7 +3,8 @@ executable = jaildoctors_dilemma
windows:
@echo off
if not exist bin\ (mkdir bin)
g++ source/*.cpp source/utils/*.cpp -std=c++11 -Wall -O2 -lmingw32 -lSDL2main -lSDL2 -o bin/$(executable).exe
g++ source/*.cpp source/utils/*.cpp -std=c++11 -Wall -O2 -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:
mkdir -p bin
g++ source/*.cpp source/utils/*.cpp -std=c++11 -Wall -O2 -lSDL2 -o bin/$(executable)_macos

View File

@@ -57,13 +57,8 @@ const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
#define SECTION_PROG_QUIT 6
// Subsecciones
#define SUBSECTION_GAME_PLAY 0
#define SUBSECTION_GAME_PAUSE 1
#define SUBSECTION_GAME_GAMEOVER 2
#define SUBSECTION_TITLE_1 3
#define SUBSECTION_TITLE_2 4
#define SUBSECTION_TITLE_3 5
#define SUBSECTION_TITLE_INSTRUCTIONS 6
#define SUBSECTION_LOGO_TO_INTRO 0
#define SUBSECTION_LOGO_TO_TITLE 1
// Colores
const color_t borderColor = {0x27, 0x27, 0x36};

View File

@@ -139,22 +139,7 @@ void Demo::update()
room->update();
scoreboard->update();
screen->updateFX();
{
counter++;
if (counter == 400)
{
counter = 0;
roomIndex++;
if (roomIndex == (int)rooms.size())
{
section.name = SECTION_PROG_TITLE;
}
else
{
changeRoom(rooms.at(roomIndex));
}
}
}
checkRoomChange();
}
}
@@ -222,3 +207,23 @@ bool Demo::changeRoom(std::string file)
return false;
}
// Comprueba si se ha de cambiar de habitación
void Demo::checkRoomChange()
{
counter++;
if (counter == 400)
{
counter = 0;
roomIndex++;
if (roomIndex == (int)rooms.size())
{
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_TITLE;
}
else
{
changeRoom(rooms.at(roomIndex));
}
}
}

View File

@@ -61,6 +61,9 @@ private:
// Cambia de habitación
bool changeRoom(std::string file);
// Comprueba si se ha de cambiar de habitación
void checkRoomChange();
public:
// Constructor
Demo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Debug *debug);

View File

@@ -7,7 +7,7 @@
Director::Director(std::string path)
{
section.name = SECTION_PROG_LOGO;
section.subsection = 0;
section.subsection = SUBSECTION_LOGO_TO_INTRO;
section.name = SECTION_PROG_CREDITS;
@@ -609,7 +609,7 @@ void Director::setSection(section_t section)
// Ejecuta la seccion de juego con el logo
void Director::runLogo()
{
logo = new Logo(renderer, screen, asset);
logo = new Logo(renderer, screen, asset, section.subsection);
setSection(logo->run());
delete logo;
}

View File

@@ -52,7 +52,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D
board.music = !debug->getEnabled();
section.name = SECTION_PROG_GAME;
section.subsection = SUBSECTION_GAME_PLAY;
section.subsection = 0;
}
Game::~Game()
@@ -174,14 +174,10 @@ section_t Game::run()
}
while (section.name == SECTION_PROG_GAME)
{
// Sección juego jugando
if (section.subsection == SUBSECTION_GAME_PLAY)
{
update();
render();
}
}
JA_StopMusic();

View File

@@ -1,7 +1,7 @@
#include "logo.h"
// Constructor
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int subsection)
{
// Copia la dirección de los objetos
this->renderer = renderer;
@@ -33,7 +33,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
// Inicializa variables
counter = 0;
section.name = SECTION_PROG_LOGO;
section.subsection = 0;
section.subsection = subsection;
ticks = 0;
ticksSpeed = 15;
initFade = 300;
@@ -237,10 +237,18 @@ void Logo::update()
// Comprueba si ha terminado el logo
if (counter == endLogo + postLogo)
{
if (section.subsection == SUBSECTION_LOGO_TO_INTRO)
{
section.name = SECTION_PROG_INTRO;
section.subsection = 0;
}
else
{
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
}
}
}
}

View File

@@ -50,7 +50,7 @@ private:
public:
// Constructor
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset);
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int subsection);
// Destructor
~Logo();