diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-07 13:06:57 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-07 13:06:57 +0100 |
commit | f4dee994b5f9019d805328d1019b4456f6bb4b2d (patch) | |
tree | 08bf5258c69a539380cefb2fa697b770efaa43f3 /constantes.h | |
parent | e984a172127c3d13ac85c29511c68784ca43984c (diff) |
game: added vim key bindings to UP/DOWN/LEFT/RIGHT
h/j/k/l are mapped to behave like arrow keys so that the navigation is
easier in the menus.
F and A are respectiverly used to validate and cancel as well.
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'constantes.h')
-rw-r--r-- | constantes.h | 180 |
1 files changed, 92 insertions, 88 deletions
diff --git a/constantes.h b/constantes.h index 415074b..1b46e77 100644 --- a/constantes.h +++ b/constantes.h @@ -49,7 +49,6 @@ #define TYPE_ATTAQUE 0 #define TYPE_MAGIE 1 - #define SELECTION(nb,nb2) if (selection == nb)\ {\ if(nb2==ALLIE)\ @@ -78,92 +77,97 @@ -#define SELECTION_CIBLE() case SDLK_RIGHT:\ - if(clan==ALLIE)\ - {\ - selection=0;\ - while(ennemis[selection].etat==MORT)\ - selection++;\ - inverse(&clan);\ - SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);\ - Fchangercurseurennemis (surfaces,positions,selection,ennemis);\ - }\ - break;\ - case SDLK_LEFT:\ - if(clan==ENNEMI)\ - {\ - SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);\ - selection=0;\ - while(persos[selection].etat==MORT)\ - selection++;\ - inverse(&clan);\ - SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositioncurseurennemis,surfaces->Pecran,&positions->Vpositioncurseurennemis);\ - Fchangercurseurpersos(surfaces,positions,selection,persos);\ - }\ - break;\ - case SDLK_UP:\ - if(clan==ENNEMI)\ - {\ - if (selection!=0)\ - selection--;\ - else\ - selection=Vnbennemis;\ - while(ennemis[selection].etat==MORT)\ - {\ - if(selection!=0)\ - selection--;\ - else\ - selection=Vnbennemis;\ - }\ - Fchangercurseurennemis (surfaces,positions,selection,ennemis);\ - }\ - else\ - {\ - if (selection!=0)\ - selection--;\ - else\ - selection=2;\ - while(persos[selection].etat==MORT)\ - {\ - if(selection!=0)\ - selection--;\ - else\ - selection=2;\ - }\ - Fchangercurseurpersos(surfaces,positions,selection,ennemis);\ - }\ - break;\ - case SDLK_DOWN:\ - if(clan==ENNEMI)\ - {\ - if(selection!=Vnbennemis)\ - selection++;\ - else\ - selection=0;\ - while(ennemis[selection].etat==MORT)\ - {\ - if(selection!=Vnbennemis)\ - selection++;\ - else\ - selection=0;\ - }\ - Fchangercurseurennemis(surfaces,positions,selection,ennemis);\ - }\ - else\ - {\ - if(selection!=2)\ - selection++;\ - else\ - selection=0;\ - while(persos[selection].etat==MORT)\ - {\ - if(selection!=2)\ - selection++;\ - else\ - selection=0;\ - }\ - Fchangercurseurpersos(surfaces,positions,selection,ennemis);\ - }\ - break; +#define SELECTION_CIBLE() \ + case SDLK_RIGHT:\ +case SDLK_l: \ +if(clan==ALLIE)\ +{\ + selection=0;\ + while(ennemis[selection].etat==MORT)\ + selection++;\ + inverse(&clan);\ + SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);\ + Fchangercurseurennemis (surfaces,positions,selection,ennemis);\ +}\ +break;\ +case SDLK_LEFT:\ +case SDLK_h: \ +if(clan==ENNEMI)\ +{\ + SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);\ + selection=0;\ + while(persos[selection].etat==MORT)\ + selection++;\ + inverse(&clan);\ + SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositioncurseurennemis,surfaces->Pecran,&positions->Vpositioncurseurennemis);\ + Fchangercurseurpersos(surfaces,positions,selection,persos);\ +}\ +break;\ +case SDLK_UP:\ +case SDLK_k: \ +if(clan==ENNEMI)\ +{\ + if (selection!=0)\ + selection--;\ + else\ + selection=Vnbennemis;\ + while(ennemis[selection].etat==MORT)\ + {\ + if(selection!=0)\ + selection--;\ + else\ + selection=Vnbennemis;\ + }\ + Fchangercurseurennemis (surfaces,positions,selection,ennemis);\ +}\ +else\ +{\ + if (selection!=0)\ + selection--;\ + else\ + selection=2;\ + while(persos[selection].etat==MORT)\ + {\ + if(selection!=0)\ + selection--;\ + else\ + selection=2;\ + }\ + Fchangercurseurpersos(surfaces,positions,selection,ennemis);\ +}\ +break;\ +case SDLK_DOWN:\ +case SDLK_j:\ +if(clan==ENNEMI)\ +{\ + if(selection!=Vnbennemis)\ + selection++;\ + else\ + selection=0;\ + while(ennemis[selection].etat==MORT)\ + {\ + if(selection!=Vnbennemis)\ + selection++;\ + else\ + selection=0;\ + }\ + Fchangercurseurennemis(surfaces,positions,selection,ennemis);\ +}\ +else\ +{\ + if(selection!=2)\ + selection++;\ + else\ + selection=0;\ + while(persos[selection].etat==MORT)\ + {\ + if(selection!=2)\ + selection++;\ + else\ + selection=0;\ + }\ + Fchangercurseurpersos(surfaces,positions,selection,ennemis);\ +}\ +break; #endif |