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
| int main (int argc, char *argv[])
{
int i = 0, z = 1;
SDL_Surface *ecran = NULL, *zozor = NULL;
SDL_Rect positionZozor[i];
SDL_Event event;
int continuer = 1;
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("Tampon Zozor",NULL);
zozor = SDL_LoadBMP("zozor.bmp");
SDL_SetColorKey(zozor,SDL_SRCCOLORKEY,SDL_MapRGB(zozor->format,0,0,255));
while(continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
continuer = 0;
break;
}
case SDL_MOUSEBUTTONUP:
if(event.button.button == SDL_BUTTON_LEFT)
{
i++; //On dit qu'à la case 1 de positionZozor, il y aura les coordonnées du premier Zozor
positionZozor[i].x = event.button.x;
positionZozor[i].y = event.button.y;
}
break;
}
SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format,255,255,255));
for(z = 1; z <= i; z++) //On affiche tout les zozor avec leurs coordonnées sauvegardés dans la positionZozor
SDL_BlitSurface(zozor,NULL,ecran,&positionZozor[z]);
SDL_Flip(ecran);
}
SDL_FreeSurface(zozor);
return EXIT_SUCCESS;
} |
Partager