From 4b8379feaad04e3e27c8589d7d75a598185382e4 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 14 Jun 2024 13:04:32 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adido=20el=20logo=20actual?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/gfx/logo.png | Bin 2512 -> 0 bytes data/gfx/logo_jailgames.png | Bin 0 -> 717 bytes data/gfx/logo_since_1998.png | Bin 0 -> 561 bytes source/director.cpp | 5 +- source/logo.cpp | 235 ++++++++++++++++++++++++++++------- source/logo.h | 47 ++++--- 6 files changed, 219 insertions(+), 68 deletions(-) delete mode 100644 data/gfx/logo.png create mode 100644 data/gfx/logo_jailgames.png create mode 100644 data/gfx/logo_since_1998.png diff --git a/data/gfx/logo.png b/data/gfx/logo.png deleted file mode 100644 index 01778853d0b868102565a2a37b26555144c497c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2512 zcmV;>2`~1EP)w^Sqf+^W*j2n>5)fTSbYD zUkm;Mw#r&5A|*RzO>EF}o|&3S=G^YNpZmS%obEjroZ*y`Hmdp{oiX*$M8Gp2S@6_6 zwlfuDOQ?q$nxK&9; zmxWJ-eY#vw_}12A1%9zPQQ$9|^>AnmoK3=>L>b4*SV`(>VR<=S=~PZB-p784Tg}YP z%GxQj9fJ@P1n@A$IAi$fXIQ+S9tP-@9ToEXe)FfvO0FVaBahAs36hxjM9oQcRo1xZ zs*DtQyZ?XtYQzTz3f0{KsD84nw{ED}g6~bs`aHC(?;~(M!bPT(pFMz~chNUXTGu`_ zuEW`7NsH~k`3AH-Xi+`-E4gGk<8gRBfrbdQTtnSrp=ZT&j_)D7CSP?0yL;f3_{OCl zO9W@xFFYao000OVNklOK)6B701sxbzgnE?e-(KlQ@$MnMoocKpF;VMnWuD zvSEQ{1%reH;u|2o0VAFtI%!W1RR&?7#R34-ZH3ho5usYE z3JW44qVM~$<_{h&48lH(1-g~#N&?L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f+^W*j2n>5)fTSbYD zUkm;Mw#r&5A|*RzO>EF}o|&3S=G^YNpZmS%obEjroZ*y`Hmdp{oiX*$M8Gp2S@6_6 zwlfuDOQ?q$nxK&9; zmxWJ-eY#vw_}12A1%9zPQQ$9|^>AnmoK3=>L>b4*SV`(>VR<=S=~PZB-p784Tg}YP z%GxQj9fJ@P1n@A$IAi$fXIQ+S9tP-@9ToEXe)FfvO0FVaBahAs36hxjM9oQcRo1xZ zs*DtQyZ?XtYQzTz3f0{KsD84nw{ED}g6~bs`aHC(?;~(M!bPT(pFMz~chNUXTGu`_ zuEW`7NsH~k`3AH-Xi+`-E4gGk<8gRBfrbdQTtnSrp=ZT&j_)D7CSP?0yL;f3_{OCl zO9W@xFFYao0001ZNkl&R|lsSA100000NkvXXu0mjfloSJg literal 0 HcmV?d00001 diff --git a/source/director.cpp b/source/director.cpp index 8188597..6f2bc6e 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -16,7 +16,7 @@ Director::Director(int argc, char *argv[]) { // Inicializa variables section = new section_t(); - section->name = SECTION_PROG_TITLE; + section->name = SECTION_PROG_LOGO; // Inicializa las opciones del programa initOptions(); @@ -287,7 +287,8 @@ bool Director::setFileList() asset->add(prefix + "/data/gfx/game_text.png", t_bitmap); asset->add(prefix + "/data/gfx/intro.png", t_bitmap); - asset->add(prefix + "/data/gfx/logo.png", t_bitmap); + asset->add(prefix + "/data/gfx/logo_jailgames.png", t_bitmap); + asset->add(prefix + "/data/gfx/logo_since_1998.png", t_bitmap); asset->add(prefix + "/data/gfx/menu_game_over.png", t_bitmap); asset->add(prefix + "/data/gfx/menu_game_over_end.png", t_bitmap); diff --git a/source/logo.cpp b/source/logo.cpp index 9aae7b2..15a166c 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -1,7 +1,5 @@ #include "logo.h" - -#define INIT_FADE 100 -#define END_LOGO 200 +#include // Constructor Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, section_t *section) @@ -15,38 +13,61 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, s // Reserva memoria para los punteros eventHandler = new SDL_Event(); - texture = new Texture(renderer, asset->get("logo.png")); - sprite = new Sprite(14, 75, 226, 44, texture, renderer); + texture = new Texture(renderer, asset->get("logo_jailgames.png")); + texture2 = new Texture(renderer, asset->get("logo_since_1998.png")); + sprite2 = new Sprite((256 - texture2->getWidth()) / 2, 83 + texture->getHeight() + 5, texture2->getWidth(), texture2->getHeight(), texture2, renderer); + sprite2->setSpriteClip(0, 0, texture2->getWidth(), texture2->getHeight()); + texture2->setColor(0, 0, 0); + + // Crea los sprites de cada linea + for (int i = 0; i < texture->getHeight(); ++i) + { + sprite.push_back(new Sprite(0, i, texture->getWidth(), 1, texture, renderer)); + sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1); + if (i % 2 == 0) + { + sprite[i]->setPosX(256 + (i * 3)); + } + else + { + sprite[i]->setPosX(-181 - (i * 3)); + } + sprite[i]->setPosY(83 + i); + } // Inicializa variables counter = 0; section->name = SECTION_PROG_LOGO; - section->subsection = 0; ticks = 0; ticksSpeed = 15; + initFade = 300; + endLogo = 400; + postLogo = 20; + + // Inicializa el vector de colores + color.push_back({0x00, 0x00, 0x00}); // Black + color.push_back({0x00, 0x00, 0xd8}); // Blue + color.push_back({0xd8, 0x00, 0x00}); // Red + color.push_back({0xd8, 0x00, 0xd8}); // Magenta + color.push_back({0x00, 0xd8, 0x00}); // Green + color.push_back({0x00, 0xd8, 0xd8}); // Cyan + color.push_back({0xd8, 0xd8, 0x00}); // Yellow + color.push_back({0xFF, 0xFF, 0xFF}); // Bright white } // Destructor Logo::~Logo() { - texture->unload(); - delete texture; + for (auto s : sprite) + { + delete s; + } - delete sprite; + delete sprite2; delete eventHandler; } -// Comprueba si ha terminado el logo -void Logo::checkLogoEnd() -{ - if (counter >= END_LOGO + 20) - { - section->name = SECTION_PROG_INTRO; - section->subsection = 0; - } -} - -// Comprueba los eventos +// Comprueba el manejador de eventos void Logo::checkEvents() { // Comprueba los eventos que hay en la cola @@ -66,7 +87,7 @@ void Logo::checkInput() { if (input->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_QUIT; + section->name = SECTION_PROG_TITLE; } else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) @@ -84,58 +105,179 @@ void Logo::checkInput() screen->incWindowSize(); } - else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE)) - { - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_1; - } + //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->subsection = SUBSECTION_TITLE_1; + // endSection(); + //} } -// Dibuja el fade -void Logo::renderFade() +// Gestiona el logo de JAILGAME +void Logo::updateJAILGAMES() { - // Dibuja el fade - if (counter >= INIT_FADE) + if (counter > 30) { - const float step = (float)(counter - INIT_FADE) / (float)(END_LOGO - INIT_FADE); - const int alpha = std::min((int)(255 * step), 255); - SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, alpha); - SDL_RenderFillRect(renderer, nullptr); + for (int i = 1; i < (int)sprite.size(); ++i) + { + const int speed = 8; + const int dest = 37; + if (sprite[i]->getPosX() != 37) + { + if (i % 2 == 0) + { + sprite[i]->incPosX(-speed); + if (sprite[i]->getPosX() < dest) + { + sprite[i]->setPosX(dest); + } + } + else + { + sprite[i]->incPosX(speed); + if (sprite[i]->getPosX() > dest) + { + sprite[i]->setPosX(dest); + } + } + } + } } } -// Actualiza las variables del objeto +// Gestiona el color de las texturas +void Logo::updateTextureColors() +{ + const int ini = 70; + const int inc = 4; + + if (counter == ini + inc * 0) + { + texture2->setColor(color[0].r, color[0].g, color[0].b); + } + + else if (counter == ini + inc * 1) + { + texture2->setColor(color[1].r, color[1].g, color[1].b); + } + + else if (counter == ini + inc * 2) + { + texture2->setColor(color[2].r, color[2].g, color[2].b); + } + + else if (counter == ini + inc * 3) + { + texture2->setColor(color[3].r, color[3].g, color[3].b); + } + + else if (counter == ini + inc * 4) + { + texture2->setColor(color[4].r, color[4].g, color[4].b); + } + + else if (counter == ini + inc * 5) + { + texture2->setColor(color[5].r, color[5].g, color[5].b); + } + + else if (counter == ini + inc * 6) + { + texture2->setColor(color[6].r, color[6].g, color[6].b); + } + + else if (counter == ini + inc * 7) + { + texture2->setColor(color[7].r, color[7].g, color[7].b); + } + + else if (counter == initFade + inc * 0) + { + texture->setColor(color[6].r, color[6].g, color[6].b); + texture2->setColor(color[6].r, color[6].g, color[6].b); + } + + else if (counter == initFade + inc * 1) + { + texture->setColor(color[5].r, color[5].g, color[5].b); + texture2->setColor(color[5].r, color[5].g, color[5].b); + } + + else if (counter == initFade + inc * 2) + { + texture->setColor(color[4].r, color[4].g, color[4].b); + texture2->setColor(color[4].r, color[4].g, color[4].b); + } + + else if (counter == initFade + inc * 3) + { + texture->setColor(color[3].r, color[3].g, color[3].b); + texture2->setColor(color[3].r, color[3].g, color[3].b); + } + + else if (counter == initFade + inc * 4) + { + texture->setColor(color[2].r, color[2].g, color[2].b); + texture2->setColor(color[2].r, color[2].g, color[2].b); + } + + else if (counter == initFade + inc * 5) + { + texture->setColor(color[1].r, color[1].g, color[1].b); + texture2->setColor(color[1].r, color[1].g, color[1].b); + } + + else if (counter == initFade + inc * 6) + { + texture->setColor(color[0].r, color[0].g, color[0].b); + texture2->setColor(color[0].r, color[0].g, color[0].b); + } +} + +// Actualiza las variables void Logo::update() { - checkInput(); - + // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { // Actualiza el contador de ticks ticks = SDL_GetTicks(); - // Actualiza el contador + // Comprueba las entradas + checkInput(); + + // Incrementa el contador counter++; + // Gestiona el logo de JAILGAME + updateJAILGAMES(); + + // Gestiona el color de las texturas + updateTextureColors(); + // Comprueba si ha terminado el logo - checkLogoEnd(); + if (counter == endLogo + postLogo) + { + section->name = SECTION_PROG_INTRO; + } } } -// Dibuja el objeto en pantalla +// Dibuja en pantalla void Logo::render() { // Prepara para empezar a dibujar en la textura de juego screen->start(); // Limpia la pantalla - screen->clean({238, 238, 238}); + screen->clean(); // Dibuja los objetos - sprite->render(); - - // Dibuja el fade - renderFade(); + for (auto s : sprite) + { + s->render(); + } + sprite2->render(); // Vuelca el contenido del renderizador en pantalla screen->blit(); @@ -144,6 +286,7 @@ void Logo::render() // Bucle para el logo del juego void Logo::run() { + // Detiene la música JA_StopMusic(); while (section->name == SECTION_PROG_LOGO) @@ -152,4 +295,4 @@ void Logo::run() checkEvents(); render(); } -} +} \ No newline at end of file diff --git a/source/logo.h b/source/logo.h index 669c25b..5e140f2 100644 --- a/source/logo.h +++ b/source/logo.h @@ -8,46 +8,53 @@ #include "common/sprite.h" #include "common/utils.h" #include "const.h" +#include #ifndef LOGO_H #define LOGO_H -// Clase Logo class Logo { private: // Objetos y punteros - SDL_Renderer *renderer; // El renderizador de la ventana - Screen *screen; // Objeto encargado de dibujar en pantalla - Asset *asset; // Objeto que gestiona todos los ficheros de recursos - Input *input; // Objeto pata gestionar la entrada - Texture *texture; // Textura con los graficos - SDL_Event *eventHandler; // Manejador de eventos - Sprite *sprite; // Sprite con la textura del logo - section_t *section; // Estado del bucle principal para saber si continua o se sale + SDL_Renderer *renderer; // El renderizador de la ventana + Screen *screen; // Objeto encargado de dibujar en pantalla + Asset *asset; // Objeto con los ficheros de recursos + Input *input; // Objeto pata gestionar la entrada + Texture *texture; // Textura con los graficos "JAILGAMES" + Texture *texture2; // Textura con los graficos "Since 1998" + SDL_Event *eventHandler; // Manejador de eventos + std::vector sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES + Sprite *sprite2; // Sprite para manejar la textura2 + options_t *options; // Puntero a las opciones del juego + section_t *section; // Estado del bucle principal para saber si continua o se sale // Variables - Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa - Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa - int counter; // Contador + std::vector color; // Vector con los colores para el fade + int counter; // Contador + Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa + Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa + int initFade; // Tiempo del contador cuando inicia el fade a negro + int endLogo; // Tiempo del contador para terminar el logo + int postLogo; // Tiempo que dura el logo con el fade al maximo - // Actualiza las variables del objeto + // Actualiza las variables void update(); - // Dibuja el objeto en pantalla + // Dibuja en pantalla void render(); - // Comprueba si ha terminado el logo - void checkLogoEnd(); - - // Comprueba los eventos + // Comprueba el manejador de eventos void checkEvents(); // Comprueba las entradas void checkInput(); - // Dibuja el fade - void renderFade(); + // Gestiona el logo de JAILGAME + void updateJAILGAMES(); + + // Gestiona el color de las texturas + void updateTextureColors(); public: // Constructor