Example #1
0
void menuPause(int* continuer,SDL_Event *even,TTF_Font *police,SDL_Surface *ecran,systEfSound *sound)
{
    //initialisation variable
    int reprendre=0,quitter=0;

    //initialisation des surfaces
    SDL_Surface *texteReprendreTTF=NULL,*texteQuitterTTF=NULL,*screen=NULL,*titreTTF=NULL;
    SDL_Rect posiText={0};
    imgMenu buton,butonOn;
    iniBouton(&buton,&butonOn,ecran);

    //remplissage
    SDL_Color couleur={255,255,255};
    texteReprendreTTF=TTF_RenderText_Blended(police,"Reprendre",couleur);
    texteQuitterTTF=TTF_RenderText_Blended(police,"Quitter",couleur);
    titreTTF=TTF_RenderText_Blended(police,"PAUSE",couleur);
    //mise en place de la transparence pour le screen
    screen=SDL_CreateRGBSurface(SDL_HWSURFACE,ecran->w,ecran->h,32,0,0,0,0);
    SDL_FillRect(screen,NULL,SDL_MapRGB(ecran->format,0,0,0));
    SDL_SetAlpha(screen,SDL_SRCALPHA,128);

    //Initialisation du type d'évennement
    even->type=NULL;

    //mise en place  du fond
    SDL_BlitSurface(screen,NULL,ecran,&posiText);

    posiText.x=ecran->w/2-titreTTF->w/2;
    posiText.y=ecran->h/4;


    do{
        SDL_BlitSurface(titreTTF,NULL,ecran,&posiText);

        reprendre=bouton(&buton,&butonOn,ecran->w/4,ecran->h/2,*even,texteReprendreTTF);
        quitter=bouton(&buton,&butonOn,ecran->w/2,ecran->h/2,*even,texteQuitterTTF);

        if(reprendre || quitter)
            Mix_PlayChannel( -1, sound->button, 0 );

        SDL_Flip(ecran);

        SDL_WaitEvent(even);
    }while( (even->type!=SDL_KEYDOWN || even->key.keysym.sym==SDLK_ESCAPE) && (!reprendre && !quitter) );
    //Si une touche clavier est enfoncé, alors on stop la pause

    //Si la touche espace est enfoncé, alors on quite le jeu
    if(even->key.keysym.sym==SDLK_SPACE || quitter )
        *continuer=0;

    SDL_FreeSurface(texteReprendreTTF);
    SDL_FreeSurface(texteQuitterTTF);
    SDL_FreeSurface(titreTTF);
    SDL_FreeSurface(screen);
    SDL_FreeSurface(buton.img);
    SDL_FreeSurface(butonOn.img);
}
Example #2
0
/* Retourne le numero de bouton si un bouton de la souris a ete enfonce,
   0 sinon */
int BoutonAppuye() {
   return bouton(fenetreCourante);
}