Skip to content

Commit

Permalink
Partial fix for issue #14: Allow jumping at the top of sloped tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Jun 22, 2015
1 parent e399bd8 commit c9ccb02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/object/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,18 @@ Player::update(float elapsed_time)

}

bool
Player::slightly_above_ground()
{
float abs_vy = std::abs(physic.get_velocity_y());
float ground_y_delta = std::abs(last_ground_y - get_pos().y);
return (abs_vy == 15.625 || abs_vy == 31.25) && ground_y_delta < 0.85;
}

bool
Player::on_ground()
{
return on_ground_flag;
return on_ground_flag || slightly_above_ground();
}

bool
Expand Down
2 changes: 2 additions & 0 deletions src/object/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ class Player : public MovingObject,
void do_jump_apex();
void early_jump_apex();

bool slightly_above_ground();

/**
* slows Tux down a little, based on where he's standing
*/
Expand Down

0 comments on commit c9ccb02

Please sign in to comment.