Skip to content

Commit ab5b8ec

Browse files
author
Semphris
committed
Replaced gentle pushback with hard floor when Tux is swimming at the bottom of a sector
1 parent 2328abc commit ab5b8ec

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

src/object/player.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ const float SMALL_TUX_HEIGHT = 30.8f;
129129
const float BIG_TUX_HEIGHT = 62.8f;
130130
const float DUCKED_TUX_HEIGHT = 31.8f;
131131

132-
/** when Tux swims down and approaches the bottom of the screen, push him back up with that strength */
133-
const float WATER_FALLOUT_FORCEBACK_STRENGTH = 1024.f;
134-
135132
bool no_water = true;
136133

137134
} // namespace
@@ -152,7 +149,6 @@ Player::Player(PlayerStatus& player_status, const std::string& name_) :
152149
m_peekingY(Direction::AUTO),
153150
m_ability_time(),
154151
m_stone(false),
155-
m_falling_below_water(false),
156152
m_swimming(false),
157153
m_swimboosting(false),
158154
m_on_left_wall(false),
@@ -523,16 +519,6 @@ Player::update(float dt_sec)
523519
m_second_growup_sound_timer.stop();
524520
}
525521

526-
// Handle player approaching the bottom of the screen while swimming
527-
if (m_falling_below_water) {
528-
m_physic.set_velocity_y(std::min(m_physic.get_velocity_y(), 0.f));
529-
}
530-
531-
if ((get_pos().y > Sector::get().get_height() - m_col.m_bbox.get_height()) && (!m_ghost_mode && m_swimming))
532-
{
533-
m_physic.set_acceleration_y(-WATER_FALLOUT_FORCEBACK_STRENGTH);
534-
}
535-
536522
if (m_boost != 0.f)
537523
{
538524
bool sign = std::signbit(m_boost);
@@ -2001,16 +1987,13 @@ Player::check_bounds()
20011987
set_pos(Vector(Sector::get().get_width() - m_col.m_bbox.get_width(), m_col.m_bbox.get_top()));
20021988
}
20031989

2004-
m_falling_below_water = false;
1990+
// If Tux is swimming, don't allow him to go below the sector
1991+
if (m_swimming && !m_ghost_mode && m_col.m_bbox.get_bottom() > Sector::get().get_height()) {
1992+
set_pos(Vector(m_col.m_bbox.get_left(), Sector::get().get_height() - m_col.m_bbox.get_height()));
1993+
}
20051994

20061995
/* fallen out of the level? */
2007-
if (m_swimming) {
2008-
// If swimming, don't kill; just prevent from falling below the ground
2009-
if ((get_pos().y > Sector::get().get_height() - 1) && (!m_ghost_mode)) {
2010-
set_pos(Vector(get_pos().x, Sector::get().get_height() - 1));
2011-
m_falling_below_water = true;
2012-
}
2013-
} else if ((get_pos().y > Sector::get().get_height()) && (!m_ghost_mode)) {
1996+
if ((get_pos().y > Sector::get().get_height()) && (!m_ghost_mode)) {
20141997
kill(true);
20151998
return;
20161999
}

src/object/player.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ class Player final : public MovingObject,
267267
Direction m_peekingY;
268268
float m_ability_time;
269269
bool m_stone;
270-
bool m_falling_below_water;
271270
bool m_swimming;
272271
bool m_swimboosting;
273272
bool m_on_left_wall;

0 commit comments

Comments
 (0)