Choisir une image au hasard en SDL

Résolu/Fermé
yoshiro Messages postés 497 Date d'inscription jeudi 1 novembre 2007 Statut Membre Dernière intervention 18 avril 2018 - 14 déc. 2008 à 00:18
yoshiro Messages postés 497 Date d'inscription jeudi 1 novembre 2007 Statut Membre Dernière intervention 18 avril 2018 - 14 déc. 2008 à 13:13
Bonjour,
voila j'essaie de mettre en place un programme en SDL qui permet de choisir une image au hasard.
Mais le programme plante.
VOICI LE CODE

   
   ....................
    
    int i=0,b,pos;
    const int min=1;
    const int max=3;
     
    positionCarte1.x = 50;
    positionCarte1.y = 10;
 ..................;;
   
   /* On charge l'image des carte : */
   ac = SDL_LoadBMP("ac.jpg");
   bc = SDL_LoadBMP("bc.jpg");
   cm = SDL_LoadBMP("cm.jpg");

 
    SDL_SetColorKey(carte, SDL_SRCCOLORKEY, SDL_MapRGB(carte->format, 0, 0, 255));
    SDL_SetColorKey(carte1, SDL_SRCCOLORKEY, SDL_MapRGB(carte->format, 0, 0, 255));
    
     while (i!=6)
   {
        pos=positionCarte1.y+15;
        b = ((double)rand() / RAND_MAX * (1 + max - min) + min); 
        switch (b)
        {
               case 1:
                     SDL_SetColorKey(ac, SDL_SRCCOLORKEY, SDL_MapRGB(carte->format, 0, 0, 255));
                     positionac.x = 50;
                     positionac.y = pos;
                     break;
               case 2:
                     SDL_SetColorKey(bc, SDL_SRCCOLORKEY, SDL_MapRGB(carte->format, 0, 0, 255));
                     positionbc.x = 50;
                     positionbc.y = pos;
                     break;
               case 3:
                     SDL_SetColorKey(cm, SDL_SRCCOLORKEY, SDL_MapRGB(carte->format, 0, 0, 255));
                     positioncm.x = 50;
                     positioncm.y = pos;
                     break;
           
         }
                    i=i+1;
   }

   SDL_BlitSurface(carte, NULL, ecran, &positionCarte);
    SDL_BlitSurface(carte1, NULL, ecran, &positionCarte1);
    SDL_BlitSurface(ac, NULL, ecran, &positionac);
    SDL_BlitSurface(bc, NULL, ecran, &positionbc);
    SDL_BlitSurface(cm, NULL, ecran, &positioncm);

             ........................     



PS: j'utilise Dev-C++
A voir également:

1 réponse

yoshiro Messages postés 497 Date d'inscription jeudi 1 novembre 2007 Statut Membre Dernière intervention 18 avril 2018 64
14 déc. 2008 à 13:13
help me!!!
0