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
|
int main(int argc, char** argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *ecran = SDL_SetVideoMode(300, 300, 32, SDL_SWSURFACE);
SDL_Surface *tux = SDL_LoadBMP("tux.bmp");
SDL_SetColorKey(tux, SDL_SRCCOLORKEY, SDL_MapRGB(tux->format, 0, 0, 255));
Uint32 couleurBlanc = SDL_MapRGB(ecran->format,255,255,255);
SDL_Event event;
int angle=1;
do{
angle+=2;
if(angle>=360)
angle=1;
// On sort de la boucle
if (SDL_PollEvent(&event)==1 && event.type==SDL_QUIT)
break;
SDL_FillRect(ecran, 0, couleurBlanc);
// La transparence est gerer.
SDL_BlitSurface(tux,NULL,ecran,NULL);
// Voici le prototype, il renvoie un SDL_Rect.
//SDL_Rect sge_transform(SDL_Surface *src, SDL_Surface *dst,float angle, float xscale
// , float yscale ,Uint16 px, Uint16 py, Uint16 qx, Uint16 qy, Uint8 flags);
// La transparence n'est plus gerer...
sge_transform(tux, ecran, angle, 1, 1, tux->w/2,tux->h/2, 150,150, SGE_TTMAP);
SDL_Flip(ecran);
}while(true);
SDL_FreeSurface(tux);
SDL_Quit();
return 0;
} |
Partager