summaryrefslogtreecommitdiff
path: root/menuprincipal.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 /menuprincipal.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 'menuprincipal.c')
-rw-r--r--menuprincipal.c172
1 files changed, 86 insertions, 86 deletions
diff --git a/menuprincipal.c b/menuprincipal.c
index 57f709f..d3b4813 100644
--- a/menuprincipal.c
+++ b/menuprincipal.c
@@ -1,86 +1,86 @@
-#include <stdlib.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-#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;
-}
-
+#include <stdlib.h>
+#include <stdlib.h>
+#include <SDL/SDL.h>
+#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;
+}
+