diff --git a/source/cheevos.cpp b/source/cheevos.cpp index cad9743..3f435a7 100644 --- a/source/cheevos.cpp +++ b/source/cheevos.cpp @@ -305,6 +305,7 @@ void Cheevos::loadFromServer() const bool incompleteData = cheevosData.length() != cheevos.size() ? true : false; if (noData || incompleteData) { + // Pone todos los logros en incompleto init(); return; } diff --git a/source/const.h b/source/const.h index 55a105b..c4e4e48 100644 --- a/source/const.h +++ b/source/const.h @@ -48,16 +48,16 @@ const int GAMECANVAS_FIRST_QUARTER_Y = GAMECANVAS_HEIGHT / 4; const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3; // Secciones del programa -#define SECTION_PROG_LOGO 0 -#define SECTION_PROG_INTRO 1 -#define SECTION_PROG_TITLE 2 -#define SECTION_PROG_CREDITS 3 -#define SECTION_PROG_GAME 4 -#define SECTION_PROG_DEMO 5 -#define SECTION_PROG_GAME_OVER 6 -#define SECTION_PROG_ENDING 7 -#define SECTION_PROG_ENDING2 8 -#define SECTION_PROG_QUIT 9 +#define SECTION_LOGO 0 +#define SECTION_LOADING_SCREEN 1 +#define SECTION_TITLE 2 +#define SECTION_CREDITS 3 +#define SECTION_GAME 4 +#define SECTION_DEMO 5 +#define SECTION_GAME_OVER 6 +#define SECTION_ENDING 7 +#define SECTION_ENDING2 8 +#define SECTION_QUIT 9 // Subsecciones #define SUBSECTION_LOGO_TO_INTRO 0 diff --git a/source/director.cpp b/source/director.cpp index f5db1ab..c87abb2 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -15,11 +15,11 @@ Director::Director(int argc, char *argv[]) { section = new section_t(); - section->name = SECTION_PROG_LOGO; + section->name = SECTION_LOGO; section->subsection = SUBSECTION_LOGO_TO_INTRO; #ifdef DEBUG - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; #endif // Crea e inicializa las opciones del programa @@ -477,7 +477,7 @@ void Director::loadResources(section_t *section) std::cout << "** LOAD RESOURCES" << std::endl; } - if (section->name == SECTION_PROG_LOGO) + if (section->name == SECTION_LOGO) { std::vector textureList; textureList.push_back("jailgames.png"); @@ -486,7 +486,7 @@ void Director::loadResources(section_t *section) resource->loadTextures(textureList); } - else if (section->name == SECTION_PROG_INTRO) + else if (section->name == SECTION_LOADING_SCREEN) { std::vector textureList; textureList.push_back("loading_screen_bn.png"); @@ -497,7 +497,7 @@ void Director::loadResources(section_t *section) resource->loadTextures(textureList); } - else if (section->name == SECTION_PROG_TITLE) + else if (section->name == SECTION_TITLE) { std::vector textureList; textureList.push_back("loading_screen_color.png"); @@ -516,7 +516,7 @@ void Director::loadResources(section_t *section) resource->loadOffsets(offsetsList); } - else if (section->name == SECTION_PROG_CREDITS) + else if (section->name == SECTION_CREDITS) { // Texturas std::vector textureList; @@ -538,7 +538,7 @@ void Director::loadResources(section_t *section) resource->loadOffsets(offsetsList); } - else if (section->name == SECTION_PROG_ENDING) + else if (section->name == SECTION_ENDING) { // Texturas std::vector textureList; @@ -563,7 +563,7 @@ void Director::loadResources(section_t *section) resource->loadOffsets(offsetsList); } - else if (section->name == SECTION_PROG_ENDING2) + else if (section->name == SECTION_ENDING2) { // Texturas std::vector textureList; @@ -701,7 +701,7 @@ void Director::loadResources(section_t *section) resource->loadOffsets(offsetsList); } - else if (section->name == SECTION_PROG_GAME_OVER) + else if (section->name == SECTION_GAME_OVER) { // Texturas std::vector textureList; @@ -725,7 +725,7 @@ void Director::loadResources(section_t *section) resource->loadOffsets(offsetsList); } - else if (section->name == SECTION_PROG_GAME || section->name == SECTION_PROG_DEMO) + else if (section->name == SECTION_GAME || section->name == SECTION_DEMO) { // Texturas std::vector textureList; @@ -1737,17 +1737,17 @@ void Director::runLogo() resource->free(); } -// Ejecuta la seccion de juego de la introducción -void Director::runIntro() +// Ejecuta la seccion de juego de la pantalla de carga +void Director::runLoadingScreen() { if (options->console) { std::cout << "\n* SECTION: INTRO" << std::endl; } loadResources(section); - intro = new Intro(renderer, screen, resource, asset, input, options, section); - intro->run(); - delete intro; + loadingScreen = new LoadingScreen(renderer, screen, resource, asset, input, options, section); + loadingScreen->run(); + delete loadingScreen; resource->free(); } @@ -1857,43 +1857,43 @@ void Director::runGame() void Director::run() { // Bucle principal - while (section->name != SECTION_PROG_QUIT) + while (section->name != SECTION_QUIT) { switch (section->name) { - case SECTION_PROG_LOGO: + case SECTION_LOGO: runLogo(); break; - case SECTION_PROG_INTRO: - runIntro(); + case SECTION_LOADING_SCREEN: + runLoadingScreen(); break; - case SECTION_PROG_TITLE: + case SECTION_TITLE: runTitle(); break; - case SECTION_PROG_CREDITS: + case SECTION_CREDITS: runCredits(); break; - case SECTION_PROG_DEMO: + case SECTION_DEMO: runDemo(); break; - case SECTION_PROG_GAME: + case SECTION_GAME: runGame(); break; - case SECTION_PROG_GAME_OVER: + case SECTION_GAME_OVER: runGameOver(); break; - case SECTION_PROG_ENDING: + case SECTION_ENDING: runEnding(); break; - case SECTION_PROG_ENDING2: + case SECTION_ENDING2: runEnding2(); break; } diff --git a/source/director.h b/source/director.h index 794ff97..ce82f25 100644 --- a/source/director.h +++ b/source/director.h @@ -10,17 +10,17 @@ #include "jail_engine/text.h" #include "jail_engine/utils.h" #include "const.h" -#include "credits.h" -#include "demo.h" -#include "ending.h" -#include "ending2.h" +#include "gamestate_credits.h" +#include "gamestate_demo.h" +#include "gamestate_ending.h" +#include "gamestate_ending2.h" #include "enter_id.h" -#include "game_over.h" -#include "game.h" -#include "intro.h" -#include "logo.h" +#include "gamestate_game_over.h" +#include "gamestate_game.h" +#include "gamestate_loading_screen.h" +#include "gamestate_logo.h" #include "online.h" -#include "title.h" +#include "gamestate_title.h" #ifndef DIRECTOR_H #define DIRECTOR_H @@ -29,25 +29,25 @@ class Director { private: // Objetos y punteros - SDL_Window *window; // La ventana donde dibujamos - SDL_Renderer *renderer; // El renderizador de la ventana - Screen *screen; // Objeto encargado de dibujar en pantalla - Resource *resource; // Objeto con los recursos - Asset *asset; // Objeto que gestiona todos los ficheros de recursos - Input *input; // Objeto Input para gestionar las entradas - Game *game; // Objeto para gestionar la sección del juego - Logo *logo; // Objeto para gestionar la sección del logo del programa - Title *title; // Objeto para gestionar la pantalla de título - Intro *intro; // Objeto para gestionar la introducción del juego - Credits *credits; // Objeto para gestionar los creditos del juego - Demo *demo; // Objeto para gestionar el modo demo, en el que se ven pantallas del juego - Ending *ending; // Objeto para gestionar el final del juego - Ending2 *ending2; // Objeto para gestionar el final del juego - GameOver *gameOver; // Objeto para gestionar el final de la partida - Debug *debug; // Objeto para getsionar la información de debug - Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto - struct options_t *options; // Variable con todas las opciones del programa - section_t *section; // Sección y subsección actual del programa; + SDL_Window *window; // La ventana donde dibujamos + SDL_Renderer *renderer; // El renderizador de la ventana + Screen *screen; // Objeto encargado de dibujar en pantalla + Resource *resource; // Objeto con los recursos + Asset *asset; // Objeto que gestiona todos los ficheros de recursos + Input *input; // Objeto Input para gestionar las entradas + Game *game; // Objeto para gestionar la sección del juego + Logo *logo; // Objeto para gestionar la sección del logo del programa + Title *title; // Objeto para gestionar la pantalla de título + LoadingScreen *loadingScreen; // Objeto para gestionar la introducción del juego + Credits *credits; // Objeto para gestionar los creditos del juego + Demo *demo; // Objeto para gestionar el modo demo, en el que se ven pantallas del juego + Ending *ending; // Objeto para gestionar el final del juego + Ending2 *ending2; // Objeto para gestionar el final del juego + GameOver *gameOver; // Objeto para gestionar el final de la partida + Debug *debug; // Objeto para getsionar la información de debug + Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto + struct options_t *options; // Variable con todas las opciones del programa + section_t *section; // Sección y subsección actual del programa; // Variables JA_Music_t *music; // Musica del titulo @@ -93,8 +93,8 @@ private: // Ejecuta la seccion de juego con el logo void runLogo(); - // Ejecuta la seccion de juego de la introducción - void runIntro(); + // Ejecuta la seccion de juego de la pantalla de carga + void runLoadingScreen(); // Ejecuta la seccion de juego con el titulo y los menus void runTitle(); diff --git a/source/enter_id.cpp b/source/enter_id.cpp index 0d030be..fb65413 100644 --- a/source/enter_id.cpp +++ b/source/enter_id.cpp @@ -72,7 +72,7 @@ void EnterID::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; loopRunning = false; break; } @@ -124,7 +124,7 @@ void EnterID::checkEvents() else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; loopRunning = false; break; } diff --git a/source/credits.cpp b/source/gamestate_credits.cpp similarity index 97% rename from source/credits.cpp rename to source/gamestate_credits.cpp index 6da6f87..6fa9205 100644 --- a/source/credits.cpp +++ b/source/gamestate_credits.cpp @@ -1,4 +1,4 @@ -#include "credits.h" +#include "gamestate_credits.h" #include // Constructor @@ -22,7 +22,7 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass counter = 0; counterEnabled = true; subCounter = 0; - section->name = SECTION_PROG_CREDITS; + section->name = SECTION_CREDITS; section->subsection = 0; ticks = 0; ticksSpeed = 15; @@ -76,7 +76,7 @@ void Credits::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; break; } } @@ -88,7 +88,7 @@ void Credits::checkInput() if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; } else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) @@ -118,7 +118,7 @@ void Credits::checkInput() else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE)) { - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; section->subsection = 0; } } @@ -283,7 +283,7 @@ void Credits::updateCounter() // Comprueba si ha terminado la sección if (counter > 1200) { - section->name = SECTION_PROG_DEMO; + section->name = SECTION_DEMO; } } @@ -344,7 +344,7 @@ void Credits::render() // Bucle para el logo del juego void Credits::run() { - while (section->name == SECTION_PROG_CREDITS) + while (section->name == SECTION_CREDITS) { update(); checkEvents(); diff --git a/source/credits.h b/source/gamestate_credits.h similarity index 100% rename from source/credits.h rename to source/gamestate_credits.h diff --git a/source/demo.cpp b/source/gamestate_demo.cpp similarity index 96% rename from source/demo.cpp rename to source/gamestate_demo.cpp index e610e10..16b5f9b 100644 --- a/source/demo.cpp +++ b/source/gamestate_demo.cpp @@ -1,4 +1,4 @@ -#include "demo.h" +#include "gamestate_demo.h" // Constructor Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug) @@ -46,7 +46,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as board.music = true; setScoreBoardColor(); - section->name = SECTION_PROG_DEMO; + section->name = SECTION_DEMO; section->subsection = 0; } @@ -69,7 +69,7 @@ void Demo::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; screen->setBorderColor(stringToColor(options->palette, "black")); break; } @@ -82,7 +82,7 @@ void Demo::checkInput() if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; } else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) @@ -116,7 +116,7 @@ void Demo::checkInput() else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE)) { - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; section->subsection = 0; } } @@ -124,7 +124,7 @@ void Demo::checkInput() // Bucle para el juego void Demo::run() { - while (section->name == SECTION_PROG_DEMO) + while (section->name == SECTION_DEMO) { update(); checkEvents(); @@ -251,7 +251,7 @@ void Demo::checkRoomChange() roomIndex++; if (roomIndex == (int)rooms.size()) { - section->name = SECTION_PROG_LOGO; + section->name = SECTION_LOGO; section->subsection = SUBSECTION_LOGO_TO_TITLE; } else diff --git a/source/demo.h b/source/gamestate_demo.h similarity index 100% rename from source/demo.h rename to source/gamestate_demo.h diff --git a/source/ending.cpp b/source/gamestate_ending.cpp similarity index 98% rename from source/ending.cpp rename to source/gamestate_ending.cpp index 2146282..182cda0 100644 --- a/source/ending.cpp +++ b/source/gamestate_ending.cpp @@ -1,4 +1,4 @@ -#include "ending.h" +#include "gamestate_ending.h" // Constructor Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section) @@ -21,7 +21,7 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset counter = -1; preCounter = 0; coverCounter = 0; - section->name = SECTION_PROG_ENDING; + section->name = SECTION_ENDING; section->subsection = 0; ticks = 0; ticksSpeed = 15; @@ -152,7 +152,7 @@ void Ending::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; break; } } @@ -164,7 +164,7 @@ void Ending::checkInput() if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_LOGO; + section->name = SECTION_LOGO; section->subsection = SUBSECTION_LOGO_TO_INTRO; } @@ -476,7 +476,7 @@ void Ending::run() { JA_PlayMusic(music); - while (section->name == SECTION_PROG_ENDING) + while (section->name == SECTION_ENDING) { update(); checkEvents(); @@ -560,7 +560,7 @@ void Ending::checkChangeScene() if (scene == 5) { // Termina el bucle - section->name = SECTION_PROG_ENDING2; + section->name = SECTION_ENDING2; // Mantiene los valores anteriores scene = 4; diff --git a/source/ending.h b/source/gamestate_ending.h similarity index 100% rename from source/ending.h rename to source/gamestate_ending.h diff --git a/source/ending2.cpp b/source/gamestate_ending2.cpp similarity index 98% rename from source/ending2.cpp rename to source/gamestate_ending2.cpp index ed62cb2..ce323b8 100644 --- a/source/ending2.cpp +++ b/source/gamestate_ending2.cpp @@ -1,4 +1,4 @@ -#include "ending2.h" +#include "gamestate_ending2.h" #include // Constructor @@ -23,7 +23,7 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass preCounter = 0; postCounter = 0; postCounterEnabled = false; - section->name = SECTION_PROG_ENDING2; + section->name = SECTION_ENDING2; section->subsection = 0; ticks = 0; ticksSpeed = 15; @@ -186,7 +186,7 @@ void Ending2::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; break; } } @@ -198,7 +198,7 @@ void Ending2::checkInput() if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_LOGO; + section->name = SECTION_LOGO; section->subsection = SUBSECTION_LOGO_TO_INTRO; } @@ -233,7 +233,7 @@ void Ending2::run() { JA_PlayMusic(music); - while (section->name == SECTION_PROG_ENDING2) + while (section->name == SECTION_ENDING2) { update(); checkEvents(); @@ -264,7 +264,7 @@ void Ending2::updateCounters() if (postCounter > 600) { - section->name = SECTION_PROG_LOGO; + section->name = SECTION_LOGO; section->subsection = SUBSECTION_LOGO_TO_INTRO; } } diff --git a/source/ending2.h b/source/gamestate_ending2.h similarity index 100% rename from source/ending2.h rename to source/gamestate_ending2.h diff --git a/source/game.cpp b/source/gamestate_game.cpp similarity index 98% rename from source/game.cpp rename to source/gamestate_game.cpp index 0ab4ce9..9529ed5 100644 --- a/source/game.cpp +++ b/source/gamestate_game.cpp @@ -1,4 +1,4 @@ -#include "game.h" +#include "gamestate_game.h" #include // Constructor @@ -87,7 +87,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled; cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados - section->name = SECTION_PROG_GAME; + section->name = SECTION_GAME; section->subsection = 0; } @@ -119,7 +119,7 @@ void Game::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; screen->setBorderColor(stringToColor(options->palette, "black")); break; } @@ -189,7 +189,7 @@ void Game::checkInput() { if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; } else if (input->checkInput(input_switch_music, REPEAT_FALSE)) @@ -242,7 +242,7 @@ void Game::run() JA_PauseMusic(); } - while (section->name == SECTION_PROG_GAME) + while (section->name == SECTION_GAME) { update(); checkEvents(); @@ -453,7 +453,7 @@ void Game::checkGameOver() { if (board.lives < 0 && blackScreenCounter > 17) { - section->name = SECTION_PROG_GAME_OVER; + section->name = SECTION_GAME_OVER; } } @@ -596,7 +596,7 @@ bool Game::checkEndGame() // Comprueba los logros de completar el juego checkEndGameCheevos(); - section->name = SECTION_PROG_ENDING; + section->name = SECTION_ENDING; return true; } diff --git a/source/game.h b/source/gamestate_game.h similarity index 100% rename from source/game.h rename to source/gamestate_game.h diff --git a/source/game_over.cpp b/source/gamestate_game_over.cpp similarity index 96% rename from source/game_over.cpp rename to source/gamestate_game_over.cpp index f88e108..124fb53 100644 --- a/source/game_over.cpp +++ b/source/gamestate_game_over.cpp @@ -1,4 +1,4 @@ -#include "game_over.h" +#include "gamestate_game_over.h" // Constructor GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section) @@ -22,7 +22,7 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A // Inicializa variables preCounter = 0; counter = 0; - section->name = SECTION_PROG_GAME_OVER; + section->name = SECTION_GAME_OVER; section->subsection = 0; ticks = 0; ticksSpeed = 15; @@ -123,7 +123,7 @@ void GameOver::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; section->subsection = 0; break; } @@ -136,7 +136,7 @@ void GameOver::checkInput() if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; } else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) @@ -168,7 +168,7 @@ void GameOver::checkInput() // Bucle principal void GameOver::run() { - while (section->name == SECTION_PROG_GAME_OVER) + while (section->name == SECTION_GAME_OVER) { update(); checkEvents(); @@ -227,7 +227,7 @@ void GameOver::updateCounters() // Comprueba si ha terminado la sección else if (counter == endSection) { - section->name = SECTION_PROG_LOGO; + section->name = SECTION_LOGO; section->subsection = SUBSECTION_LOGO_TO_TITLE; } } diff --git a/source/game_over.h b/source/gamestate_game_over.h similarity index 100% rename from source/game_over.h rename to source/gamestate_game_over.h diff --git a/source/intro.cpp b/source/gamestate_loading_screen.cpp similarity index 90% rename from source/intro.cpp rename to source/gamestate_loading_screen.cpp index 9c3cf73..e815a9a 100644 --- a/source/intro.cpp +++ b/source/gamestate_loading_screen.cpp @@ -1,7 +1,7 @@ -#include "intro.h" +#include "gamestate_loading_screen.h" // Constructor -Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section) +LoadingScreen::LoadingScreen(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section) { // Copia la dirección de los objetos this->resource = resource; @@ -33,7 +33,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset * // Inicializa variables preCounter = 0; counter = 0; - section->name = SECTION_PROG_INTRO; + section->name = SECTION_LOADING_SCREEN; section->subsection = 0; ticks = 0; ticksSpeed = 15; @@ -65,7 +65,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset * } // Destructor -Intro::~Intro() +LoadingScreen::~LoadingScreen() { delete sprite1; delete sprite2; @@ -76,7 +76,7 @@ Intro::~Intro() } // Comprueba el manejador de eventos -void Intro::checkEvents() +void LoadingScreen::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -84,19 +84,19 @@ void Intro::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; break; } } } // Comprueba las entradas -void Intro::checkInput() +void LoadingScreen::checkInput() { if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; } else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) @@ -126,13 +126,13 @@ void Intro::checkInput() else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE)) { - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; section->subsection = 0; } } // Gestiona el contador de carga -void Intro::updateLoad() +void LoadingScreen::updateLoad() { // Primera parte de la carga, la parte en blanco y negro if (loadingFirstPart) @@ -172,7 +172,7 @@ void Intro::updateLoad() // Comprueba si ha terminado la intro if (loadCounter >= 768) { - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; section->subsection = 0; JA_StopMusic(); } @@ -180,7 +180,7 @@ void Intro::updateLoad() } // Gestiona el contador interno -void Intro::updateCounter() +void LoadingScreen::updateCounter() { (preCounter >= 50) ? counter++ : preCounter++; @@ -191,13 +191,13 @@ void Intro::updateCounter() } // Dibuja la pantalla de carga -void Intro::renderLoad() +void LoadingScreen::renderLoad() { loadingFirstPart ? sprite1->render() : sprite2->render(); } // Dibuja el efecto de carga en el borde -void Intro::renderBorder() +void LoadingScreen::renderBorder() { // Pinta el borde de colro azul color_t color = stringToColor(options->palette, "blue"); @@ -233,7 +233,7 @@ void Intro::renderBorder() } // Actualiza las variables -void Intro::update() +void LoadingScreen::update() { // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) @@ -256,7 +256,7 @@ void Intro::update() } // Dibuja en pantalla -void Intro::render() +void LoadingScreen::render() { if (options->borderEnabled) { @@ -278,7 +278,7 @@ void Intro::render() } // Bucle para el logo del juego -void Intro::run() +void LoadingScreen::run() { // Inicia el sonido de carga JA_SetVolume(64); @@ -289,7 +289,7 @@ void Intro::run() screen->clean(); screen->blit(); - while (section->name == SECTION_PROG_INTRO) + while (section->name == SECTION_LOADING_SCREEN) { update(); checkEvents(); @@ -300,7 +300,7 @@ void Intro::run() } // Cambia la paleta -void Intro::switchPalette() +void LoadingScreen::switchPalette() { if (options->palette == p_zxspectrum) { @@ -319,7 +319,7 @@ void Intro::switchPalette() } // Reconstruye la pantalla de carga -void Intro::recreateLoadingScreen() +void LoadingScreen::recreateLoadingScreen() { // Prepara para empezar a dibujar en la textura de juego screen->start(); diff --git a/source/intro.h b/source/gamestate_loading_screen.h similarity index 91% rename from source/intro.h rename to source/gamestate_loading_screen.h index c40b348..2a6ea2d 100644 --- a/source/intro.h +++ b/source/gamestate_loading_screen.h @@ -14,10 +14,10 @@ #include #include "jail_engine/text.h" -#ifndef INTRO_H -#define INTRO_H +#ifndef LOADING_SCREEN_H +#define LOADING_SCREEN_H -class Intro +class LoadingScreen { private: // Objetos y punteros @@ -79,10 +79,10 @@ private: public: // Constructor - Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section); + LoadingScreen(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section); // Destructor - ~Intro(); + ~LoadingScreen(); // Bucle principal void run(); diff --git a/source/logo.cpp b/source/gamestate_logo.cpp similarity index 96% rename from source/logo.cpp rename to source/gamestate_logo.cpp index ed51def..a26fc69 100644 --- a/source/logo.cpp +++ b/source/gamestate_logo.cpp @@ -1,4 +1,4 @@ -#include "logo.h" +#include "gamestate_logo.h" #include // Constructor @@ -39,7 +39,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as // Inicializa variables counter = 0; - section->name = SECTION_PROG_LOGO; + section->name = SECTION_LOGO; ticks = 0; ticksSpeed = 15; initFade = 300; @@ -78,7 +78,7 @@ void Logo::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; break; } } @@ -89,7 +89,7 @@ void Logo::checkInput() { if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; } else if (input->checkInput(input_toggle_border, REPEAT_FALSE)) @@ -303,7 +303,7 @@ void Logo::run() // Detiene la música JA_StopMusic(); - while (section->name == SECTION_PROG_LOGO) + while (section->name == SECTION_LOGO) { update(); checkEvents(); @@ -322,11 +322,11 @@ void Logo::endSection() { if (section->subsection == SUBSECTION_LOGO_TO_TITLE) { - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; } else if (section->subsection == SUBSECTION_LOGO_TO_INTRO) { - section->name = SECTION_PROG_INTRO; + section->name = SECTION_LOADING_SCREEN; } } \ No newline at end of file diff --git a/source/logo.h b/source/gamestate_logo.h similarity index 100% rename from source/logo.h rename to source/gamestate_logo.h diff --git a/source/title.cpp b/source/gamestate_title.cpp similarity index 98% rename from source/title.cpp rename to source/gamestate_title.cpp index 3b45acd..0775bec 100644 --- a/source/title.cpp +++ b/source/gamestate_title.cpp @@ -1,4 +1,4 @@ -#include "title.h" +#include "gamestate_title.h" // Constructor Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, Online *online, options_t *options, section_t *section) @@ -41,7 +41,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset * // Inicializa variables counter = 0; - section->name = SECTION_PROG_TITLE; + section->name = SECTION_TITLE; section->subsection = 0; ticks = 0; ticksSpeed = 15; @@ -97,7 +97,7 @@ void Title::checkEvents() // Evento de salida de la aplicación if (eventHandler->type == SDL_QUIT) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; break; } @@ -109,7 +109,7 @@ void Title::checkEvents() switch (eventHandler->key.keysym.scancode) { case SDL_SCANCODE_1: - section->name = SECTION_PROG_GAME; + section->name = SECTION_GAME; section->subsection = 0; break; @@ -157,7 +157,7 @@ void Title::checkInput() } else { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_QUIT; } } @@ -194,7 +194,7 @@ void Title::checkInput() { if (!showCheevos) { - // section->name = SECTION_PROG_GAME; + // section->name = SECTION_GAME; // section->subsection = 0; } } @@ -278,7 +278,7 @@ void Title::update() { if (!showCheevos) { - section->name = SECTION_PROG_CREDITS; + section->name = SECTION_CREDITS; section->subsection = 0; } } @@ -310,7 +310,7 @@ void Title::render() // Bucle para el logo del juego void Title::run() { - while (section->name == SECTION_PROG_TITLE) + while (section->name == SECTION_TITLE) { update(); checkEvents(); diff --git a/source/title.h b/source/gamestate_title.h similarity index 100% rename from source/title.h rename to source/gamestate_title.h