diff --git a/source/intro.cpp b/source/intro.cpp index 9fb2f66..9c3cf73 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -196,6 +196,42 @@ void Intro::renderLoad() loadingFirstPart ? sprite1->render() : sprite2->render(); } +// Dibuja el efecto de carga en el borde +void Intro::renderBorder() +{ + // Pinta el borde de colro azul + color_t color = stringToColor(options->palette, "blue"); + SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF); + SDL_RenderClear(renderer); + + // Añade lineas amarillas + color = stringToColor(options->palette, "yellow"); + SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF); + const int width = GAMECANVAS_WIDTH + (options->borderWidth * 2); + const int height = GAMECANVAS_HEIGHT + (options->borderHeight * 2); + bool drawEnabled = rand() % 2 == 0 ? true : false; + // for (int i = 0; i < height; ++i) + //{ + // if (rand() % 2 == 0) + // { + // SDL_RenderDrawLine(renderer, 0, i, width, i); + // } + // } + int row = 0; + int rowSize = 1; + while (row < height) + { + rowSize = (rand() % 4) + 3; + if (drawEnabled) + for (int i = row; i < row + rowSize; ++i) + { + SDL_RenderDrawLine(renderer, 0, i, width, i); + } + row += rowSize; + drawEnabled = !drawEnabled; + } +} + // Actualiza las variables void Intro::update() { @@ -222,6 +258,15 @@ void Intro::update() // Dibuja en pantalla void Intro::render() { + if (options->borderEnabled) + { + // Prepara para empezar a dibujar en la textura del borde + screen->startDrawOnBorder(); + + // Dibuja el efecto de carga en el borde + renderBorder(); + } + // Prepara para empezar a dibujar en la textura de juego screen->start(); diff --git a/source/intro.h b/source/intro.h index 51bf5be..c40b348 100644 --- a/source/intro.h +++ b/source/intro.h @@ -68,6 +68,9 @@ private: // Dibuja la pantalla de carga void renderLoad(); + // Dibuja el efecto de carga en el borde + void renderBorder(); + // Cambia la paleta void switchPalette(); diff --git a/source/logo.cpp b/source/logo.cpp index d017f4d..ed51def 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -320,5 +320,13 @@ void Logo::switchPalette() // Termina la sección void Logo::endSection() { - section->name = SECTION_PROG_INTRO; + if (section->subsection == SUBSECTION_LOGO_TO_TITLE) + { + section->name = SECTION_PROG_TITLE; + } + + else if (section->subsection == SUBSECTION_LOGO_TO_INTRO) + { + section->name = SECTION_PROG_INTRO; + } } \ No newline at end of file