From 58852efe0561498aca378fb612e16d1c212cd29d Mon Sep 17 00:00:00 2001 From: oroborus Date: Wed, 4 Jun 2008 12:38:40 +0000 Subject: - pri drzani dvoch klaves sa tux nezasekne ;) git-svn-id: http://opensvn.csie.org/tuxanci_ng@60 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- config.h | 4 +- src/screen_world.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 2147311..1b1e335 100644 --- a/config.h +++ b/config.h @@ -6,8 +6,8 @@ #define DEBUG_CLIENT_RECV */ -#define TUXANCI_NG_VERSION "svn58" +#define TUXANCI_NG_VERSION "svn60" #define DESTDIR "/usr/local/" #define SUPPORT_NET_SDL_UDP -#define PUBLIC_SERVER +//#define PUBLIC_SERVER diff --git a/src/screen_world.c b/src/screen_world.c index b158dee..4f1e8d8 100644 --- a/src/screen_world.c +++ b/src/screen_world.c @@ -212,40 +212,75 @@ static void netAction(tux_t *tux, int action) static void control_keyboard_right(tux_t *tux) { + static int lastKey = 0; + int countKey; Uint8 *mapa; mapa = SDL_GetKeyState(NULL); assert( tux != NULL ); assert( mapa != NULL ); + countKey = 0; + + if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED )countKey++; + if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED )countKey++; + if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED )countKey++; + if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED )countKey++; + if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED ) { + if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_UP) )goto tuUp; + + if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_UP); netAction(tux, TUX_UP); actionTux(tux, TUX_UP); + return; + + tuUp:; } if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED ) { + if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_RIGHT) )goto tuRight; + + if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_RIGHT); netAction(tux, TUX_RIGHT); actionTux(tux, TUX_RIGHT); + return; + + tuRight:; + } if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED ) { + if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_LEFT) )goto tuLeft; + + if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_LEFT); netAction(tux, TUX_LEFT); actionTux(tux, TUX_LEFT); + return; + + tuLeft:; } if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED ) { + if(countKey > 1 && lastKey == getKey(KEY_TUX_RIGHT_MOVE_DOWN) )goto tuDown; + + if( countKey == 1 )lastKey = getKey(KEY_TUX_RIGHT_MOVE_DOWN); netAction(tux, TUX_DOWN); actionTux(tux, TUX_DOWN); + return; + + tuDown:; } if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE ) { netAction(tux, TUX_SHOT); actionTux(tux, TUX_SHOT); + return; } if( mapa[(SDLKey)getKey(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED ) @@ -254,18 +289,88 @@ static void control_keyboard_right(tux_t *tux) { netAction(tux, TUX_SWITCH_GUN); actionTux(tux, TUX_SWITCH_GUN); + return; } } } static void control_keyboard_left(tux_t *tux) { + static int lastKey = 0; + int countKey; Uint8 *mapa; mapa = SDL_GetKeyState(NULL); assert( tux != NULL ); assert( mapa != NULL ); + countKey = 0; + + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )countKey++; + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )countKey++; + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )countKey++; + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED )countKey++; + + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED ) + { + if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_UP) )goto tuUp; + + if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_UP); + actionTux(tux, TUX_UP); + return; + + tuUp:; + } + + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED ) + { + if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_RIGHT) )goto tuRight; + + if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_RIGHT); + actionTux(tux, TUX_RIGHT); + return; + + tuRight:; + + } + + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED ) + { + if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_LEFT) )goto tuLeft; + + if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_LEFT); + actionTux(tux, TUX_LEFT); + return; + + tuLeft:; + } + + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED ) + { + if(countKey > 1 && lastKey == getKey(KEY_TUX_LEFT_MOVE_DOWN) )goto tuDown; + + if( countKey == 1 )lastKey = getKey(KEY_TUX_LEFT_MOVE_DOWN); + actionTux(tux, TUX_DOWN); + return; + + tuDown:; + } + + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED && tux->isCanShot == TRUE ) + { + actionTux(tux, TUX_SHOT); + return; + } + + if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED ) + { + if( tux->isCanSwitchGun == TRUE ) + { + actionTux(tux, TUX_SWITCH_GUN); + return; + } + } +/* if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED )actionTux(tux, TUX_UP); if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED )actionTux(tux, TUX_RIGHT); if( mapa[(SDLKey)getKey(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED )actionTux(tux, TUX_LEFT); @@ -279,6 +384,7 @@ static void control_keyboard_left(tux_t *tux) actionTux(tux, TUX_SWITCH_GUN); } } +*/ } static void eventEsc() -- cgit v1.2.3