From f290b8cd7e40ed8688175fba312697f7da96a34e Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 26 Oct 2014 18:15:21 +0000 Subject: game: Add a buildable version of the agme Signed-off-by: Olivier Gayot --- menuprincipal.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 menuprincipal.c (limited to 'menuprincipal.c') diff --git a/menuprincipal.c b/menuprincipal.c new file mode 100644 index 0000000..57f709f --- /dev/null +++ b/menuprincipal.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include "structures.h" +#include "prototypes.h" +#include "constantes.h" + +void Fmenuprincipal (SURFACES *surfaces, POSITIONS *positions) +{ + int continuer = 1; + SDL_Event event; + int Vmode = 0; + SDL_BlitSurface (surfaces->Pmenujouer,NULL,surfaces->Pecran,&positions->Vpositionmenu); + SDL_Flip (surfaces->Pecran); + while (continuer) + { + SDL_WaitEvent (&event); + switch (event.type) + { + case SDL_KEYDOWN: + switch (event.key.keysym.sym) + { + case SDLK_DOWN: + + if (Vmode < 2) + { + Vmode++; + Fchangersurlignage (Vmode,surfaces,positions); + } + else + { + Vmode = 0; + Fchangersurlignage (Vmode,surfaces,positions); + } + break; + case SDLK_UP: + if (Vmode > 0) + { + Vmode--; + Fchangersurlignage (Vmode,surfaces,positions); + } + else + { + Vmode = 2; + Fchangersurlignage (Vmode,surfaces,positions); + } + break; + case SDLK_RETURN: + continuer = Fentrermode (Vmode,surfaces,positions); + Vmode = 0; + if (continuer) + { + SDL_BlitSurface (surfaces->Pmenujouer,NULL,surfaces->Pecran,&positions->Vpositionmenu); + SDL_Flip (surfaces->Pecran); + } + break; + } + break; + } + } +} + +void Fchangersurlignage (int Vmode, SURFACES *surfaces, POSITIONS *positions) +{ + if (Vmode == 0) + SDL_BlitSurface (surfaces->Pmenujouer,NULL,surfaces->Pecran,&positions->Vpositionmenu); + else if (Vmode == 1) + SDL_BlitSurface (surfaces->Pmenuoptions,NULL,surfaces->Pecran,&positions->Vpositionmenu); + else if (Vmode == 2) + SDL_BlitSurface (surfaces->Pmenuquitter,NULL,surfaces->Pecran,&positions->Vpositionmenu); + SDL_Flip (surfaces->Pecran); +} + +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; +} + -- cgit v1.2.3