J´ai maintenant essayé de modifier le premier tuto SDL de JYY ( toujours le même) :
void waitkey() // attend qu´on appuie sur RETURN
{
while(1) // boucle
{
while(SDL_PollEvent(&)) // aquisition d´evenement
{
if ( event.type == SDL_KEYDOWN) / / on appuie sur une touche ?
{
if ( event.key.keysym.sym == SDLK_SPACE) return; / / c´est " RETURN" ?
}
}
}
}
void droite() // attend qu´on appuie sur RETURN
{
while(1) // boucle
{
while(SDL_PollEvent(&)) // aquisition d´evenement
{
if ( event.type == SDL_KEYDOWN) / / on appuie sur une touche ?
{
if ( event.key.keysym.sym == SDLK_RIGHT) / / c´est " RETURN" ?
{
rect1.x = 50;
return;
}
}
}
}
}
void gauche() // attend qu´on appuie sur RETURN
{
while(1) // boucle
{
while(SDL_PollEvent(&)) // aquisition d´evenement
{
if ( event.type == SDL_KEYDOWN) / / on appuie sur une touche ?
{
if ( event.key.keysym.sym == SDLK_LEFT) / / c´est " RETURN" ?
{
rect1.x = -50;
return;
}
}
}
}
}
int main(int argc , char **argv)
{
SDL_Rect rect1; // structure rectangle
prepare_SDL(); // initialise ( plus haut)
firstscreen = SDL_LoadBMP("image.bmp"); // charge l´image
/ / on dessine
rect1.x = 0;
rect1.y = 0;
rect1.w = 1024; // défini le rectangle
rect1.h = 768;
SDL_BlitSurface(firstscreen,NULL,screen,&1); /
/ colle l´image sur l´écran, NULL car on affiche TOUTE l´image
SDL_Flip(screen); // affiche la prochaine frame
droite();
gauche();
waitkey(); // attends qu´on appuie sur Return ( plus haut)
SDL_ShowCursor(1); // reactive la souris
SDL_Quit(); // quitte SDL
return 0; // quitte le programme
}
Et ça bloque sur la ligne " rect1.x = 50". Pourquoi ?