Añadido degradado en el fondo

This commit is contained in:
2023-05-07 09:16:35 +02:00
parent f89579c6e5
commit 5b19caa89b

View File

@@ -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);
}