[Super-tux-commit] supertux/src gameloop.cpp,1.86,1.87 globals.cpp,1.14,1.15 globals.h,1.26,1.27 men
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-20 16:26:58
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32204 Modified Files: gameloop.cpp globals.cpp globals.h menu.cpp player.cpp player.h worldmap.cpp Log Message: - moved joystick mappings into a struct Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- menu.cpp 20 Apr 2004 10:42:04 -0000 1.41 +++ menu.cpp 20 Apr 2004 16:25:57 -0000 1.42 @@ -634,7 +634,7 @@ } break; case SDL_JOYAXISMOTION: - if(event.jaxis.axis == JOY_Y) + if(event.jaxis.axis == joystick_keymap.y_axis) { if (event.jaxis.value > 1024) menuaction = MENU_ACTION_DOWN; Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- player.h 20 Apr 2004 11:09:34 -0000 1.30 +++ player.h 20 Apr 2004 16:26:06 -0000 1.31 @@ -46,13 +46,16 @@ #include <vector> -struct player_keymap_type +struct PlayerKeymap { +public: int jump; int duck; int left; int right; int fire; + + PlayerKeymap(); }; struct player_input_type @@ -101,9 +104,7 @@ class Player { - public: - player_keymap_type keymap; - +public: player_input_type input; bool got_coffee; int size; @@ -123,7 +124,7 @@ Timer frame_timer; Physic physic; - public: +public: void init(); int key_event(SDLKey key, int state); void level_begin(); @@ -140,10 +141,14 @@ bool on_ground(); bool under_solid(); - private: +private: void handle_horizontal_input(); void handle_vertical_input(); void remove_powerups(); }; #endif /*SUPERTUX_PLAYER_H*/ + +/* Local Variables: */ +/* mode:c++ */ +/* End: */ Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- globals.cpp 20 Apr 2004 12:24:28 -0000 1.14 +++ globals.cpp 20 Apr 2004 16:25:57 -0000 1.15 @@ -23,12 +23,19 @@ /** The datadir prefix prepended when loading game data file */ std::string datadir; -int JOY_A = 0; -int JOY_B = 1; -int JOY_START = 9; +JoystickKeymap::JoystickKeymap() +{ + a_button = 0; + b_button = 1; + start_button = 9; + + x_axis = 0; + y_axis = 1; + + dead_zone = 4096; +} -int JOY_X = 0; -int JOY_Y = 1; +JoystickKeymap joystick_keymap; SDL_Surface * screen; Text* black_text; @@ -47,7 +54,7 @@ bool use_fullscreen; bool debug_mode; bool show_fps; -float game_speed = 1.0f; +float game_speed = 1.2f; int joystick_num = 0; char* level_startup_file = 0; Index: globals.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- globals.h 20 Apr 2004 12:24:28 -0000 1.26 +++ globals.h 20 Apr 2004 16:25:57 -0000 1.27 @@ -30,13 +30,21 @@ extern std::string datadir; -/* Joystick buttons and axes: */ -extern int JOY_A; -extern int JOY_B; -extern int JOY_START; +struct JoystickKeymap +{ + int a_button; + int b_button; + int start_button; -extern int JOY_X; -extern int JOY_Y; + int x_axis; + int y_axis; + + int dead_zone; + + JoystickKeymap(); +}; + +extern JoystickKeymap joystick_keymap; extern SDL_Surface * screen; extern Text* black_text; @@ -70,6 +78,4 @@ int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false); -#define JOYSTICK_DEAD_ZONE 4096 - #endif /* SUPERTUX_GLOBALS_H */ Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- player.cpp 20 Apr 2004 11:09:34 -0000 1.46 +++ player.cpp 20 Apr 2004 16:25:57 -0000 1.47 @@ -59,6 +59,17 @@ Surface* bigcape_right[2]; Surface* bigcape_left[2]; +PlayerKeymap keymap; + +PlayerKeymap::PlayerKeymap() +{ + keymap.jump = SDLK_UP; + keymap.duck = SDLK_DOWN; + keymap.left = SDLK_LEFT; + keymap.right = SDLK_RIGHT; + keymap.fire = SDLK_LCTRL; +} + void player_input_init(player_input_type* pplayer_input) { pplayer_input->down = UP; @@ -96,12 +107,6 @@ player_input_init(&input); - keymap.jump = SDLK_UP; - keymap.duck = SDLK_DOWN; - keymap.left = SDLK_LEFT; - keymap.right = SDLK_RIGHT; - keymap.fire = SDLK_LCTRL; - invincible_timer.init(true); skidding_timer.init(true); safe_timer.init(true); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- worldmap.cpp 20 Apr 2004 12:24:28 -0000 1.39 +++ worldmap.cpp 20 Apr 2004 16:26:08 -0000 1.40 @@ -408,26 +408,26 @@ break; case SDL_JOYAXISMOTION: - if (event.jaxis.axis == JOY_X) + if (event.jaxis.axis == joystick_keymap.x_axis) { - if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + if (event.jaxis.value < -joystick_keymap.dead_zone) input_direction = WEST; - else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + else if (event.jaxis.value > joystick_keymap.dead_zone) input_direction = EAST; } - else if (event.jaxis.axis == JOY_Y) + else if (event.jaxis.axis == joystick_keymap.y_axis) { - if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + if (event.jaxis.value > joystick_keymap.dead_zone) input_direction = SOUTH; - else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + else if (event.jaxis.value < -joystick_keymap.dead_zone) input_direction = NORTH; } break; case SDL_JOYBUTTONDOWN: - if (event.jbutton.button == JOY_B) + if (event.jbutton.button == joystick_keymap.b_button) enter_level = true; - else if (event.jbutton.button == JOY_START) + else if (event.jbutton.button == joystick_keymap.start_button) on_escape_press(); break; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- gameloop.cpp 20 Apr 2004 12:24:28 -0000 1.86 +++ gameloop.cpp 20 Apr 2004 16:25:56 -0000 1.87 @@ -280,14 +280,14 @@ break; case SDL_JOYAXISMOTION: - if (event.jaxis.axis == JOY_X) + if (event.jaxis.axis == joystick_keymap.x_axis) { - if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + if (event.jaxis.value < -joystick_keymap.dead_zone) { tux.input.left = DOWN; tux.input.right = UP; } - else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + else if (event.jaxis.value > joystick_keymap.dead_zone) { tux.input.left = UP; tux.input.right = DOWN; @@ -298,11 +298,11 @@ tux.input.right = DOWN; } } - else if (event.jaxis.axis == JOY_Y) + else if (event.jaxis.axis == joystick_keymap.y_axis) { - if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + if (event.jaxis.value > joystick_keymap.dead_zone) tux.input.down = DOWN; - else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + else if (event.jaxis.value < -joystick_keymap.dead_zone) tux.input.down = UP; else tux.input.down = UP; @@ -310,17 +310,17 @@ break; case SDL_JOYBUTTONDOWN: - if (event.jbutton.button == JOY_A) + if (event.jbutton.button == joystick_keymap.a_button) tux.input.up = DOWN; - else if (event.jbutton.button == JOY_B) + else if (event.jbutton.button == joystick_keymap.b_button) tux.input.fire = DOWN; - else if (event.jbutton.button == JOY_START) + else if (event.jbutton.button == joystick_keymap.start_button) on_escape_press(); break; case SDL_JOYBUTTONUP: - if (event.jbutton.button == JOY_A) + if (event.jbutton.button == joystick_keymap.a_button) tux.input.up = UP; - else if (event.jbutton.button == JOY_B) + else if (event.jbutton.button == joystick_keymap.b_button) tux.input.fire = UP; break; |