1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include <stdlib.h>
#include <stdio.h>
#include <sdl/sdl.h>
int main( int argc , char *argv[] )
{
SDL_Surface *ecran[256] = {NULL};
SDL_Event event ;
int i = 0 , j = 256 ;
int continuer = 1 ;
SDL_Init(SDL_INIT_VIDEO);
for(i = 0 ; i <= 255 ; i++)
ecran[i] = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("Le Fond Ecran En SDL",NULL);
SDL_EnableKeyRepeat(10,10);
while(continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT :
continuer = 0 ;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_UP :
for(i = 0 ; i <= 255 ; i++ )
SDL_FillRect(ecran[i],NULL,SDL_MapRGB(ecran[i]->format,i,i,i));
break;
case SDLK_DOWN :
for(j <= 255 ; j= 0 ; j--)
SDL_FillRect(ecran[j],NULL,SDL_MapRGB(ecran[j]->format,j,j,j));
break;
}break;
}
for(i = 0 ; i <= 255 ; i++)
SDL_FillRect(ecran[i],NULL,SDL_MapRGB(ecran[i]->format,0,0,0));
SDL_Flip(ecran[i]);
}
for ( i = 0 ; i <= 255 ; i++)
for ( j<=255 ; j=0 ; j--)
SDL_FreeSurface(ecran[i]);
SDL_FreeSurface(ecran[j]);
SDL_Quit();
return EXIT_SUCCESS;
} |
Partager