Skip to content

Commit

Permalink
* Don't kill Tux after winning a level. (Bug 675)
Browse files Browse the repository at this point in the history
* Support for heavy objects which slow Tux down.

SVN-Revision: 6682
  • Loading branch information
uafr committed Apr 17, 2011
1 parent f03fa22 commit 5cf9fcc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/object/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ Player::init()
dead = false;

dying = false;
winning = false;
peekingX = AUTO;
peekingY = AUTO;
last_ground_y = 0;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()))
Expand Down
10 changes: 10 additions & 0 deletions src/object/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ class Player : public MovingObject,
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;
Expand Down Expand Up @@ -258,6 +267,7 @@ class Player : public MovingObject,

private:
bool dying;
bool winning;
bool backflipping;
int backflip_direction;
Direction peekingX;
Expand Down
9 changes: 9 additions & 0 deletions src/object/portable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class Portable
{
return true;
}

/**
* Is the object so heavy/bulky/fragile that Tux can't run while
* carrying it?
*/
virtual bool is_hampering()
{
return false;
}
};

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/supertux/game_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GameObject*>::iterator i = currentsector->gameobjects.begin();
Expand Down

0 comments on commit 5cf9fcc

Please sign in to comment.