forked from jaildesigner-jailgames/jaildoctors_dilemma
Ya rueda por los diferentes estados del juego: logo, titulo, creditos, demo
This commit is contained in:
3
Makefile
3
Makefile
@@ -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
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
@@ -175,12 +175,8 @@ section_t Game::run()
|
||||
|
||||
while (section.name == SECTION_PROG_GAME)
|
||||
{
|
||||
// Sección juego jugando
|
||||
if (section.subsection == SUBSECTION_GAME_PLAY)
|
||||
{
|
||||
update();
|
||||
render();
|
||||
}
|
||||
update();
|
||||
render();
|
||||
}
|
||||
|
||||
JA_StopMusic();
|
||||
@@ -243,9 +239,9 @@ void Game::render()
|
||||
// Pasa la información de debug
|
||||
void Game::updateDebugInfo()
|
||||
{
|
||||
debug->add("X = " + std::to_string((int)player->x) + ", Y = " + std::to_string((int)player->y));
|
||||
debug->add("VX = " + std::to_string(player->vx).substr(0, 4) + ", VY = " + std::to_string(player->vy).substr(0, 4));
|
||||
debug->add("STATE = " + std::to_string(player->state));
|
||||
debug->add("X = " + std::to_string((int)player->x) + ", Y = " + std::to_string((int)player->y));
|
||||
debug->add("VX = " + std::to_string(player->vx).substr(0, 4) + ", VY = " + std::to_string(player->vy).substr(0, 4));
|
||||
debug->add("STATE = " + std::to_string(player->state));
|
||||
}
|
||||
|
||||
// Pone la información de debug en pantalla
|
||||
|
||||
@@ -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;
|
||||
@@ -238,8 +238,16 @@ void Logo::update()
|
||||
// Comprueba si ha terminado el logo
|
||||
if (counter == endLogo + postLogo)
|
||||
{
|
||||
section.name = SECTION_PROG_INTRO;
|
||||
section.subsection = 0;
|
||||
if (section.subsection == SUBSECTION_LOGO_TO_INTRO)
|
||||
{
|
||||
section.name = SECTION_PROG_INTRO;
|
||||
section.subsection = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user