From 5b19caa89bf6a18cf786c94e1f2c45c3c1695455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Sun, 7 May 2023 09:16:35 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adido=20degradado=20en=20el=20fondo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 9263e98..c1a6a07 100644 --- a/main.cpp +++ b/main.cpp @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) Text *text = new Text("data/smb2.txt", "data/smb2.png", renderer); // Bucle principal - JA_PlayMusic(music, true); + // JA_PlayMusic(music, true); bool should_exit = false; while (!should_exit) { @@ -73,7 +73,21 @@ int main(int argc, char *argv[]) // Dibuja en pantalla SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); SDL_RenderClear(renderer); - text->writeCentered(options->gameWidth / 2 ,text->getCharacterSize(),"Jail Engine DEMO"); + // Dibuja un degradado de fondo + const int gradFirstLine = options->gameHeight / 3; + const int gradLastLine = options->gameHeight; + const int gradNumLines = gradLastLine - gradFirstLine; + const int gradColorFrom = 0; + const int gradColorTo = 192; + + for (int i = gradFirstLine; i < gradLastLine; ++i) + { + float step = ((float)(i - gradFirstLine) / gradNumLines); + int color = gradColorFrom + ((gradColorTo - gradColorFrom) * step); + SDL_SetRenderDrawColor(renderer, color, 0x00, 0x00, 0xFF); + SDL_RenderDrawLine(renderer, 0, i, options->gameWidth, i); + } + text->writeCentered(options->gameWidth / 2, text->getCharacterSize(), "Jail Engine DEMO"); SDL_RenderPresent(renderer); }