Make title fade in.
This commit is contained in:
parent
51d3b66ab9
commit
0ac4fd0989
21
Spacewar.c
21
Spacewar.c
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue