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 --- menuchoixpersos.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 menuchoixpersos.c (limited to 'menuchoixpersos.c') diff --git a/menuchoixpersos.c b/menuchoixpersos.c new file mode 100644 index 0000000..8db15df --- /dev/null +++ b/menuchoixpersos.c @@ -0,0 +1,154 @@ +#include +#include +#include +#include "structures.h" +#include "constantes.h" +#include "prototypes.h" +#include +#include + +void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions) +{ + + int nbpersos = 0; + TTF_Font *police = NULL; + int Vchoix = 0; + SDL_Color vert; + unsigned int continuer = 1; + PERSONNAGES persos[3]; + ENNEMIS ennemis[5]; + SDL_Event event; + int Vnbperso = 0; + + vert.r = 39; + vert.g = 189; + vert.b = 31; + SDL_BlitSurface (surfaces->Pchoixpaladin,NULL,surfaces->Pecran,&positions->Vpositionmenu); + police = TTF_OpenFont ("C://WINDOWS//Fonts//TIMESI.TTF",36); + while (Vnbperso!=3) + { + continuer = 1; + if (Vnbperso == 0) + surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police,"Choisissez la Classe de votre Premier Personnage",vert); + else if (Vnbperso == 1) + surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police,"Choisissez la Classe de votre Deuxième Personnage",vert); + else if (Vnbperso == 2) + surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police,"Choisissez la Classe de votre Troisième Personnage",vert); + positions->Vpositiontextemenu.x=XWIN/2-surfaces->Ptextechoixmenu->w/2; + if (persos[Vnbperso-1].classe == PALADIN) + SDL_BlitSurface (surfaces->Pchoixpaladin,NULL,surfaces->Pecran,&positions->Vpositionmenu); + if (persos[Vnbperso-1].classe == PRETRE) + SDL_BlitSurface (surfaces->Pchoixpretre,NULL,surfaces->Pecran,&positions->Vpositionmenu); + if (persos[Vnbperso-1].classe == VOLEUR) + SDL_BlitSurface (surfaces->Pchoixvoleur,NULL,surfaces->Pecran,&positions->Vpositionmenu); + SDL_BlitSurface (surfaces->Ppretre,NULL,surfaces->Pecran,&positions->Vpositionmenupretre); + SDL_BlitSurface (surfaces->Ppaladin,NULL,surfaces->Pecran,&positions->Vpositionmenupaladin); + SDL_BlitSurface (surfaces->Pvoleur,NULL,surfaces->Pecran,&positions->Vpositionmenuvoleur); + SDL_BlitSurface (surfaces->Ptextechoixmenu,NULL,surfaces->Pecran,&positions->Vpositiontextemenu); + SDL_Flip (surfaces->Pecran); + while (continuer) + { + SDL_WaitEvent (&event); + switch (event.type) + { + case SDL_KEYDOWN: + switch (event.key.keysym.sym) + { + case SDLK_LEFT: + if(Vchoix>PALADIN) + { + Vchoix--; + Fchangersurlignage2 (Vchoix,surfaces,positions); + } + else + { + Vchoix=VOLEUR; + Fchangersurlignage2 (Vchoix,surfaces,positions); + } + break; + case SDLK_RIGHT: + if (VchoixPecran); + Fremplirpersos2 (surfaces,persos); + Fmap(surfaces,positions,persos,ennemis); +} + +void Fchangersurlignage2 (int Vchoix, SURFACES *surfaces, POSITIONS *positions) +{ + if (Vchoix==PALADIN) + SDL_BlitSurface (surfaces->Pchoixpaladin,NULL,surfaces->Pecran,&positions->Vpositionmenu); + else if (Vchoix==PRETRE) + SDL_BlitSurface (surfaces->Pchoixpretre,NULL,surfaces->Pecran,&positions->Vpositionmenu); + else if (Vchoix==VOLEUR) + SDL_BlitSurface (surfaces->Pchoixvoleur,NULL,surfaces->Pecran,&positions->Vpositionmenu); + SDL_BlitSurface (surfaces->Ppretre,NULL,surfaces->Pecran,&positions->Vpositionmenupretre); + SDL_BlitSurface (surfaces->Ppaladin,NULL,surfaces->Pecran,&positions->Vpositionmenupaladin); + SDL_BlitSurface (surfaces->Pvoleur,NULL,surfaces->Pecran,&positions->Vpositionmenuvoleur); + SDL_BlitSurface (surfaces->Ptextechoixmenu,NULL,surfaces->Pecran,&positions->Vpositiontextemenu); + SDL_Flip (surfaces->Pecran); +} + +void Fremplirpersos (int Vchoix, PERSONNAGES persos[],int Vnbpersos) +{ + if (Vchoix==PALADIN) + persos[Vnbpersos].classe=PALADIN; + else if (Vchoix==PRETRE) + persos[Vnbpersos].classe=PRETRE; + else if (Vchoix==VOLEUR) + persos[Vnbpersos].classe=VOLEUR; +} + +void Fremplirpersos2 (SURFACES *surfaces, PERSONNAGES persos[]) +{ + + int i; + for (i=0;i<3;i++) + { + if (persos[i].classe==PALADIN) + surfaces->Tperso[i]=IMG_Load("images/paladin.bmp"); + else if (persos[i].classe==PRETRE) + surfaces->Tperso[i]=IMG_Load("images/prêtre.bmp"); + else if (persos[i].classe==VOLEUR) + surfaces->Tperso[i]=IMG_Load("images/voleur.bmp"); + } +} + +void Fremplirennemis (SURFACES *surfaces,int Vnbennemis,ENNEMIS ennemis[]) +{ + + int i; + for (i=0;i<=Vnbennemis;i++) + { + if (ennemis[i].classe==GUERRIER_GOBELIN) + surfaces->Tennemi[i]=surfaces->Pgobelin; + } +} + +int Fcalculernbennemis () +{ + int nb; + nb=(rand()%(4-0+1))+0; + return nb; +} + -- cgit v1.2.3