diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2014-10-26 18:15:21 +0000 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2014-10-26 18:15:21 +0000 |
commit | f290b8cd7e40ed8688175fba312697f7da96a34e (patch) | |
tree | b9671094c14db5cd26bf5578dd95e19803eb6560 /menuchoixpersos.c |
game: Add a buildable version of the agme
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'menuchoixpersos.c')
-rw-r--r-- | menuchoixpersos.c | 154 |
1 files changed, 154 insertions, 0 deletions
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 <stdlib.h>
+#include <stdio.h>
+#include <SDL/SDL.h>
+#include "structures.h"
+#include "constantes.h"
+#include "prototypes.h"
+#include <SDL/SDL_image.h>
+#include <SDL/SDL_ttf.h>
+
+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 (Vchoix<VOLEUR)
+ {
+ Vchoix++;
+ Fchangersurlignage2 (Vchoix,surfaces,positions);
+ }
+ else
+ {
+ Vchoix=PALADIN;
+ Fchangersurlignage2 (Vchoix,surfaces,positions);
+ }
+ break;
+ case SDLK_RETURN:
+ Fremplirpersos (Vchoix,persos,Vnbperso);
+ Vnbperso++;
+ continuer=0;
+ break;
+ }
+ break;
+ }
+ }
+ }
+ TTF_CloseFont (police);
+ SDL_Flip(surfaces->Pecran);
+ 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;
+}
+
|