From: Wolfgang Becker Date: Sun, 17 Apr 2011 16:15:43 +0000 (+0000) Subject: * Don't kill Tux after winning a level. (Bug 675) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5cf9fcc222f720e912e9aaea963828e34118be95;p=supertux.git * Don't kill Tux after winning a level. (Bug 675) * Support for heavy objects which slow Tux down. SVN-Revision: 6682 --- diff --git a/src/object/player.cpp b/src/object/player.cpp index 55ffc0080..22b2b4f05 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -199,6 +199,7 @@ Player::init() dead = false; dying = false; + winning = false; peekingX = AUTO; peekingY = AUTO; last_ground_y = 0; @@ -262,6 +263,15 @@ Player::set_controller(Controller* controller) this->controller = controller; } +void +Player::set_winning() +{ + if( ! is_winning() ){ + winning = true; + invincible_timer.start(10000.0f); + } +} + void Player::use_scripting_controller(bool use_or_release) { @@ -480,8 +490,8 @@ Player::handle_horizontal_input() } } - // do not run if we're holding something - if ( false /* grabbed_extra_heavy_object */) { + // do not run if we're holding something which slows us down + if ( grabbed_object && grabbed_object->is_hampering() ) { ax = dirsign * WALK_ACCELERATION_X; // limit speed if(vx >= MAX_WALK_XM && dirsign > 0) { @@ -1258,7 +1268,7 @@ Player::make_invincible() void Player::kill(bool completely) { - if(dying || deactivated) + if(dying || deactivated || is_winning() ) return; if(!completely && (safe_timer.started() || invincible_timer.started())) diff --git a/src/object/player.hpp b/src/object/player.hpp index b59345561..b54a294ec 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -62,6 +62,15 @@ public: virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx); void set_controller(Controller* controller); + /* + * Level solved. Don't kill Tux any more. + */ + void set_winning(); + bool is_winning() + { + return winning; + } + Controller* get_controller() { return controller; @@ -258,6 +267,7 @@ private: private: bool dying; + bool winning; bool backflipping; int backflip_direction; Direction peekingX; diff --git a/src/object/portable.hpp b/src/object/portable.hpp index 5fbabf4e5..87b6af30e 100644 --- a/src/object/portable.hpp +++ b/src/object/portable.hpp @@ -45,6 +45,15 @@ public: { return true; } + + /** + * Is the object so heavy/bulky/fragile that Tux can't run while + * carrying it? + */ + virtual bool is_hampering() + { + return false; + } }; #endif diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index 65db0454c..56c2a9bc2 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -578,7 +578,7 @@ GameSession::start_sequence(const std::string& sequencename) end_sequence->start(); sound_manager->play_music("music/leveldone.ogg", false); - currentsector->player->invincible_timer.start(10000.0f); + currentsector->player->set_winning(); // Stop all clocks. for(std::vector::iterator i = currentsector->gameobjects.begin();