From f4dee994b5f9019d805328d1019b4456f6bb4b2d Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 7 Jan 2015 13:06:57 +0100 Subject: 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 --- constantes.h | 180 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 92 insertions(+), 88 deletions(-) (limited to 'constantes.h') 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 -- cgit v1.2.3