summaryrefslogtreecommitdiff
path: root/menuchoixpersos.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2014-10-26 18:20:28 +0000
committerOlivier Gayot <duskcoder@gmail.com>2014-10-26 18:20:54 +0000
commite816f16a5007798968f4c9003b3159a45485e88f (patch)
tree86be1ca571b383ba1d532fa655991d099903732a /menuchoixpersos.c
parentf290b8cd7e40ed8688175fba312697f7da96a34e (diff)
game: remove useless checks
it is safe to pass a null pointer to SDL_FreeSurface() BTW: change the format of the files from dos to unix Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'menuchoixpersos.c')
-rw-r--r--menuchoixpersos.c308
1 files changed, 154 insertions, 154 deletions
diff --git a/menuchoixpersos.c b/menuchoixpersos.c
index 8db15df..6c5f9b7 100644
--- a/menuchoixpersos.c
+++ b/menuchoixpersos.c
@@ -1,154 +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;
-}
-
+#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;
+}
+