From c49323cfdfc2b000324981dd261fee21715c3a85 Mon Sep 17 00:00:00 2001 From: Sergio Date: Sun, 8 Oct 2023 14:24:18 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adido=20efectos=20en=20el=20borde=20para?= =?UTF-8?q?=20imitar=20la=20carga=20de=20la=20pantalla=20como=20en=20el=20?= =?UTF-8?q?spectrum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/intro.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ source/intro.h | 3 +++ source/logo.cpp | 10 +++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/source/intro.cpp b/source/intro.cpp index 9fb2f666..9c3cf731 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 51bf5beb..c40b3485 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 d017f4d1..ed51def8 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