From: Wolfgang Becker Date: Sat, 20 Jan 2007 13:45:36 +0000 (+0000) Subject: Make Tux run automatically. As before, if he is carrying something Tux X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;ds=sidebyside;h=91fe7b591a749415c896857cfc1a8a9edf53c870;p=supertux.git Make Tux run automatically. As before, if he is carrying something Tux can only walk. To reduce the speed to 'walk', hold the 'Action' key. SVN-Revision: 4610 --- diff --git a/src/object/player.cpp b/src/object/player.cpp index 46588010d..ea2fedfeb 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -379,8 +379,9 @@ Player::handle_horizontal_input() } } - // only run if action key is pressed and we're not holding anything - if (!(controller->hold(Controller::ACTION) && (!grabbed_object))) { + // do not run if action key is pressed or we're holding something + // so tux can only walk while shooting + if ( controller->hold(Controller::ACTION) || grabbed_object ) { ax = dirsign * WALK_ACCELERATION_X; // limit speed if(vx >= MAX_WALK_XM && dirsign > 0) { @@ -391,7 +392,11 @@ Player::handle_horizontal_input() ax = 0; } } else { - ax = dirsign * RUN_ACCELERATION_X; + if( vx * dirsign < MAX_WALK_XM ) { + ax = dirsign * WALK_ACCELERATION_X; + } else { + ax = dirsign * RUN_ACCELERATION_X; + } // limit speed if(vx >= MAX_RUN_XM && dirsign > 0) { vx = MAX_RUN_XM;