summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--menuchoixpersos.c47
-rw-r--r--structures.h6
2 files changed, 35 insertions, 18 deletions
diff --git a/menuchoixpersos.c b/menuchoixpersos.c
index 325eadc..cc217a8 100644
--- a/menuchoixpersos.c
+++ b/menuchoixpersos.c
@@ -10,9 +10,9 @@
void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
{
TTF_Font *police = NULL;
- int Vchoix = 0;
+ int Vchoix = PALADIN;
SDL_Color vert;
- unsigned int continuer = 1;
+ bool continuer = true;
PERSONNAGES persos[3];
ENNEMIS ennemis[5];
SDL_Event event;
@@ -21,29 +21,40 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
vert.r = 39;
vert.g = 189;
vert.b = 31;
- SDL_BlitSurface (surfaces->Pchoixpaladin,NULL,surfaces->Pecran,&positions->Vpositionmenu);
+
police = TTF_OpenFont ("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)
+
+ /* loop until we have actually chosen our three characters */
+ while (Vnbperso < 3) {
+ static const char *strings[] = {
+ "Please choose the class of your first character",
+ "Please choose the class of your second character",
+ "Please choose the class of your third character",
+ };
+
+ /* display the background with the selected text */
+ if (Vchoix == PALADIN) {
SDL_BlitSurface (surfaces->Pchoixpaladin,NULL,surfaces->Pecran,&positions->Vpositionmenu);
- if (persos[Vnbperso-1].classe == PRETRE)
+ } else if (Vchoix == PRETRE) {
SDL_BlitSurface (surfaces->Pchoixpretre,NULL,surfaces->Pecran,&positions->Vpositionmenu);
- if (persos[Vnbperso-1].classe == VOLEUR)
+ } else if (Vchoix == VOLEUR) {
SDL_BlitSurface (surfaces->Pchoixvoleur,NULL,surfaces->Pecran,&positions->Vpositionmenu);
+ } else {
+ abort();
+ }
+
+ /* display the string associated with the current character number (aka Please choose ...) */
+ surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police, strings[Vnbperso], vert);
+
+ positions->Vpositiontextemenu.x=XWIN/2-surfaces->Ptextechoixmenu->w/2;
+ SDL_BlitSurface (surfaces->Ptextechoixmenu,NULL,surfaces->Pecran,&positions->Vpositiontextemenu);
+
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);
+
+ continuer = true;
while (continuer)
{
SDL_WaitEvent (&event);
@@ -82,7 +93,7 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
case SDLK_f:
Fremplirpersos (Vchoix,persos,Vnbperso);
Vnbperso++;
- continuer=0;
+ continuer = false;
break;
default:
break;
diff --git a/structures.h b/structures.h
index fdb2ecb..19d0a1e 100644
--- a/structures.h
+++ b/structures.h
@@ -12,9 +12,15 @@ struct surfaces
SDL_Surface *Pmenuoptions;
SDL_Surface *Pmenujouer;
SDL_Surface *Pmenuquitter;
+
+ /*
+ * the 3 following structures are actually an image of a menu with
+ * respectively the text "Paladin", "Pretre" or "Voleur" selected
+ */
SDL_Surface *Pchoixpaladin;
SDL_Surface *Pchoixpretre;
SDL_Surface *Pchoixvoleur;
+
SDL_Surface *Tperso[3];
SDL_Surface *Tennemi[5];
SDL_Surface *Ptextechoixmenu;