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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| #include<stdio.h>
#include<stdlib.h>
#include<SDL/SDL.h>
int main(int argc, char *argv[])
{
SDL_Surface *ecran=NULL, *photo1=NULL, *photo2=NULL, *photo3=NULL;
SDL_Rect position1, position2, position3;
SDL_Event evene;
int continuer=1, x1, y1;
if(SDL_Init(SDL_INIT_VIDEO)==-1)
{
fprintf(stderr,"Erreur Impossible d'ouvrir votre fenetre SDL: %s\n",SDL_GetError());
exit(EXIT_FAILURE);
}
SDL_WM_SetIcon(SDL_LoadBMP("icone.bmp"), NULL);
SDL_WM_SetCaption("Photo!!!",NULL);
ecran=SDL_SetVideoMode(710,682,32,SDL_HWSURFACE| SDL_DOUBLEBUF);
SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format, 122, 38, 99));
photo1=SDL_LoadBMP("photo1.bmp");
photo2=SDL_LoadBMP("photo2.bmp");
photo3=SDL_LoadBMP("photo3.bmp");
position1.x=0;
position1.y=0;
position2.x=0;
position2.y=228;
position3.x=0;
position3.y=455;
SDL_BlitSurface(photo1,NULL, ecran, &position1);
SDL_BlitSurface(photo2,NULL, ecran, &position2);
SDL_BlitSurface(photo3,NULL, ecran, &position3);
SDL_Flip(ecran);
SDL_EnableKeyRepeat(10,10);
while(continuer)
{
SDL_WaitEvent(&evene);
switch(evene.type)
{
case SDL_QUIT:
continuer=0;break;
case SDL_MOUSEBUTTONUP:
switch(evene.button.button)
{
case SDL_BUTTON_LEFT:
position1.x=evene.button.x;
position1.y=evene.button.y;
x1=evene.button.x;
y1=evene.button.y;break;
case SDL_BUTTON_RIGHT:
position1.x=x1;
position1.y=y1;
break;
}
break;
}
SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format, 122, 38, 99));
photo1=SDL_LoadBMP("photo1.bmp");
photo2=SDL_LoadBMP("photo2.bmp");
photo3=SDL_LoadBMP("photo3.bmp");
SDL_BlitSurface(photo1,NULL, ecran, &position1);
SDL_BlitSurface(photo2,NULL, ecran, &position2);
SDL_BlitSurface(photo3,NULL, ecran, &position3);
SDL_Flip(ecran);
}
SDL_FreeSurface(photo1);
SDL_FreeSurface(photo2);
SDL_FreeSurface(photo3);
SDL_Quit();
return EXIT_SUCCESS;
} |
Partager