diff --git a/Makefile b/Makefile index f1a21fa..96b7e5f 100644 --- a/Makefile +++ b/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 diff --git a/source/const.h b/source/const.h index 86e9442..8d96fac 100644 --- a/source/const.h +++ b/source/const.h @@ -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}; diff --git a/source/demo.cpp b/source/demo.cpp index fd60efb..a69ad7c 100644 --- a/source/demo.cpp +++ b/source/demo.cpp @@ -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(); } } @@ -221,4 +206,24 @@ 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)); + } + } } \ No newline at end of file diff --git a/source/demo.h b/source/demo.h index faed501..b7728df 100644 --- a/source/demo.h +++ b/source/demo.h @@ -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); diff --git a/source/director.cpp b/source/director.cpp index c54ed00..ef08466 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -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; } diff --git a/source/game.cpp b/source/game.cpp index 8e73224..8956e51 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -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 diff --git a/source/logo.cpp b/source/logo.cpp index 9aaaeb7..5df8df6 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -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; + } } } } diff --git a/source/logo.h b/source/logo.h index de02c88..ef28c1a 100644 --- a/source/logo.h +++ b/source/logo.h @@ -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();