#include #include #include #include "structures.h" #include "prototypes.h" #include "constantes.h" static void Fchangersurlignage(int Vmode, SURFACES *surfaces) { SDL_Surface *surf; if (Vmode == 0) surf = surfaces->Pmenujouer; else if (Vmode == 1) surf = surfaces->Pmenuoptions; else if (Vmode == 2) surf = surfaces->Pmenuquitter; SDL_BlitSurface(surf, NULL, surfaces->screen, NULL); SDL_Flip(surfaces->screen); } void Fmenuprincipal (SURFACES *surfaces, POSITIONS *positions) { int continuer = 1; SDL_Event event; int Vmode = 0; SDL_BlitSurface(surfaces->Pmenujouer, NULL, surfaces->screen, NULL); SDL_Flip (surfaces->Pecran); while (continuer) { SDL_WaitEvent (&event); switch (event.type) { case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_DOWN: case SDLK_j: if (Vmode < 2) { Vmode++; Fchangersurlignage(Vmode, surfaces); } else { Vmode = 0; Fchangersurlignage(Vmode, surfaces); } break; case SDLK_UP: case SDLK_k: if (Vmode > 0) { Vmode--; Fchangersurlignage(Vmode, surfaces); } else { Vmode = 2; Fchangersurlignage(Vmode, surfaces); } break; case SDLK_RETURN: case SDLK_f: continuer = Fentrermode (Vmode,surfaces,positions); Vmode = 0; if (continuer) { SDL_BlitSurface(surfaces->Pmenujouer, NULL, surfaces->screen, NULL); SDL_Flip (surfaces->Pecran); } break; default: break; } break; } } } int Fentrermode (int Vmode, SURFACES *surfaces, POSITIONS *positions) { int continuer = 1; if (Vmode == 0) Fmenuchoixpersos (surfaces,positions); else if (Vmode == 1) Foptions (surfaces,positions); else if (Vmode == 2) continuer = 0; return continuer; }