Voici mon code :<sup>
#include <SDL/SDL.h>
SDL_Surface * sEcran ;
SDL_Surface * sImage ;
void init()
{
SDL_Init(SDL_INIT_VIDEO) ;
sEcran = SDL_SetVideoMode(800, 600, 32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN) ;
SDL_ShowCursor(0) ;
sImage=SDL_LoadBMP("img.bmp") ;
SDL_SetColorKey(sImage, SDL_SRCCOLORKEY, SDL_MapRGB(sImage->format,0,0,0)) ;
}
void Quit()
{
SDL_FreeSurface(sImage) ;
SDL_FreeSurface(sEcran) ;
SDL_ShowCursor(1) ;
SDL_Quit() ;
exit(0) ;
}
int main(int argc, char *argv[])
{
init() ;
int up
0 , down 0, right = 0 , left = 0 ;
SDL_Event event ;
SDL_Rect rect, dest ;
rect.x = 0 ;
rect.y = 0 ;
rect.w = 80 ;
rect.h = 80 ;
dest.x = 360 ;
dest.y = 260 ;
dest.w = 80 ;
dest.h = 80 ;
while(true)
{
while(SDL_PollEvent(&event))
{
if(event.type==SDL_QUIT)
{
Quit();
}
else if(event.type==SDL_KEYDOWN)
{
if(event.key.keysym.sym==SDLK_ESCAPE)
Quit() ;
}
}
SDL_FillRect(sEcran,NULL,SDL_MapRGB(sEcran->format,8,63,15)) ;
SDL_BlitSurface(sImage,&rect,sEcran,&dest) ;
SDL_FillRect(sEcran,&rect,SDL_MapRGB(sEcran->format,4,63,55)) ;
SDL_Flip(sEcran);
}
return 0 ;
}
</sup>Le code marche bien mais quand je met
SDL_SetColorKey(sImage, SDL_SRCCOLORKEY, SDL_MapRGB(sImage->format,0,0,0)) ;
le programme se lance et quitte, je comprend pas d'où vient le pbsurtout que sans cette commande le prog marche correctement...
Merci d'avance pour l'aide que vous pourrais me fournir
Afficher la suite