Make title fade in.

This commit is contained in:
Barra Ó Catháin 2023-03-22 09:27:26 +00:00
parent 51d3b66ab9
commit 0ac4fd0989
1 changed files with 20 additions and 1 deletions

View File

@ -125,7 +125,7 @@ int main(int argc, char ** argv)
SDL_Rect textDestination = {0, 0, text->w, text->h}; SDL_Rect textDestination = {0, 0, text->w, text->h};
SDL_Texture * textTexture = SDL_CreateTextureFromSurface(renderer, text); SDL_Texture * textTexture = SDL_CreateTextureFromSurface(renderer, text);
int scrollX = 0; int scrollX = 0, titleAlpha = 0, textAlpha = 0;
// Render the title text: // Render the title text:
while(!inputSelected) while(!inputSelected)
{ {
@ -159,8 +159,27 @@ int main(int argc, char ** argv)
{ {
scrollX = 0; scrollX = 0;
} }
SDL_SetTextureAlphaMod(titleTexture, titleAlpha);
SDL_RenderCopy(renderer, titleTexture, NULL, &titleRect); SDL_RenderCopy(renderer, titleTexture, NULL, &titleRect);
if(titleAlpha < 254)
{
titleAlpha += 10;
}
if(titleAlpha >= 254)
{
titleAlpha = 254;
}
SDL_SetTextureAlphaMod(textTexture, textAlpha);
SDL_RenderCopy(renderer, textTexture, NULL, &textDestination); SDL_RenderCopy(renderer, textTexture, NULL, &textDestination);
if(textAlpha < 254 && titleAlpha == 254)
{
textAlpha += 20;
}
if(textAlpha >= 254)
{
textAlpha = 254;
}
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
SDL_PumpEvents(); SDL_PumpEvents();