diff --git a/data/font/smb2.png b/data/font/smb2.png index b11fade..45fa64b 100644 Binary files a/data/font/smb2.png and b/data/font/smb2.png differ diff --git a/source/credits.cpp b/source/credits.cpp index e1b1321..e8dad3c 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -45,7 +45,7 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset) texts.push_back("MADE ON SUMMER/FALL 2022"); texts.push_back(""); texts.push_back(""); - texts.push_back("LOVE JAILGAMES!"); + texts.push_back("LOVE JAILGAMES!}"); texts.push_back(""); // Crea la textura para el texto que se escribe en pantalla @@ -56,6 +56,14 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset) } SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND); + // Crea la textura para cubrir el rexto + coverTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT); + if (coverTexture == nullptr) + { + printf("Error: coverTexture could not be created!\nSDL Error: %s\n", SDL_GetError()); + } + SDL_SetTextureBlendMode(coverTexture, SDL_BLENDMODE_BLEND); + // Escribe el texto en la textura fillTexture(); } @@ -65,6 +73,8 @@ Credits::~Credits() { delete eventHandler; delete text; + SDL_DestroyTexture(textTexture); + SDL_DestroyTexture(coverTexture); } // Comprueba el manejador de eventos @@ -104,6 +114,7 @@ void Credits::checkEventHandler() // Escribe el texto en la textura void Credits::fillTexture() { + // Rellena la textura de texto SDL_SetRenderTarget(renderer, textTexture); SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00); SDL_RenderClear(renderer); @@ -112,13 +123,39 @@ void Credits::fillTexture() const int size = text->getCharacterSize(); int i = 0; - for (auto t:texts) + for (auto t : texts) { text->write(0, i * size, t); i++; } SDL_SetRenderTarget(renderer, nullptr); + + // Rellena la textura que cubre el texto + SDL_SetRenderTarget(renderer, coverTexture); + SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00); + SDL_RenderClear(renderer); + + // Los primeros 8 pixels crea una malla + SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); + for (int i = 0; i < 256; i += 2) + { + SDL_RenderDrawPoint(renderer, i, 0); + SDL_RenderDrawPoint(renderer, i, 2); + SDL_RenderDrawPoint(renderer, i, 4); + SDL_RenderDrawPoint(renderer, i, 6); + + SDL_RenderDrawPoint(renderer, i + 1, 1); + SDL_RenderDrawPoint(renderer, i + 1, 3); + SDL_RenderDrawPoint(renderer, i + 1, 5); + SDL_RenderDrawPoint(renderer, i + 1, 7); + } + + // El resto se rellena de color + SDL_Rect rect = {0, 8, 256, 192}; + SDL_RenderFillRect(renderer, &rect); + + SDL_SetRenderTarget(renderer, nullptr); } // Actualiza las variables @@ -153,10 +190,13 @@ void Credits::render() // Limpia la pantalla screen->clean(); - SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; + // Dibuja la textura con el texto en pantalla + SDL_RenderCopy(renderer, textTexture, nullptr, nullptr); - // Dibuja la textura con el mapa en pantalla - SDL_RenderCopy(renderer, textTexture, &rect, nullptr); + // Dibuja la textura que cubre el texto + const int offset = std::min(counter / 4, 192 / 2); + SDL_Rect rect = {0, offset * 2, 256, 192}; + SDL_RenderCopy(renderer, coverTexture, nullptr, &rect); // Vuelca el contenido del renderizador en pantalla screen->blit(); diff --git a/source/credits.h b/source/credits.h index 9ffee40..8a05bb5 100644 --- a/source/credits.h +++ b/source/credits.h @@ -24,17 +24,21 @@ private: bool enabled; // Solo se escriben y mueven si estan habilitadas }; - SDL_Renderer *renderer; // El renderizador de la ventana - Screen *screen; // Objeto encargado de dibujar en pantalla - Asset *asset; // Objeto con los ficheros de recursos - SDL_Event *eventHandler; // Manejador de eventos - Text *text; // Objeto para escribir texto en pantalla + // Objetos + SDL_Renderer *renderer; // El renderizador de la ventana + Screen *screen; // Objeto encargado de dibujar en pantalla + Asset *asset; // Objeto con los ficheros de recursos + SDL_Event *eventHandler; // Manejador de eventos + Text *text; // Objeto para escribir texto en pantalla + SDL_Texture *textTexture; // Textura para dibujar el texto + SDL_Texture *coverTexture; // Textura para cubrir el texto + + // Variables int counter; // Contador section_t section; // Estado del bucle principal para saber si continua o se sale Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa std::vector texts; // Vector con las letras de la marquesina - SDL_Texture *textTexture; // Textura para dibujar el texto // Actualiza las variables void update(); diff --git a/source/director.cpp b/source/director.cpp index c82ea50..a97da6e 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -9,7 +9,7 @@ Director::Director(std::string path) section.name = SECTION_PROG_GAME; section.subsection = 0; - section.name = SECTION_PROG_INTRO; + section.name = SECTION_PROG_TITLE; // Crea el objeto que controla los ficheros de recursos asset = new Asset(path.substr(0, path.find_last_of("\\/"))); diff --git a/source/title.cpp b/source/title.cpp index d13015f..8e29ce7 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -22,6 +22,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset) ticks = 0; ticksSpeed = 15; longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME P.A.C.O. THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?"; + longText = "HEY JAILERS!!"; for (int i = 0; i < (int)longText.length(); ++i) { letter_t l;