Skip to content

Commit 2ef42e8

Browse files
authored
Merge pull request #2035 from Semphriss/water-floor
Replaced gentle pushback with hard floor when Tux is swimming at the bottom of a sector
2 parents 7018b07 + ab5b8ec commit 2ef42e8

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),
@@ -526,16 +522,6 @@ Player::update(float dt_sec)
526522
m_second_growup_sound_timer.stop();
527523
}
528524

529-
// Handle player approaching the bottom of the screen while swimming
530-
if (m_falling_below_water) {
531-
m_physic.set_velocity_y(std::min(m_physic.get_velocity_y(), 0.f));
532-
}
533-
534-
if ((get_pos().y > Sector::get().get_height() - m_col.m_bbox.get_height()) && (!m_ghost_mode && m_swimming))
535-
{
536-
m_physic.set_acceleration_y(-WATER_FALLOUT_FORCEBACK_STRENGTH);
537-
}
538-
539525
if (m_boost != 0.f)
540526
{
541527
bool sign = std::signbit(m_boost);
@@ -2004,16 +1990,13 @@ Player::check_bounds()
20041990
set_pos(Vector(Sector::get().get_width() - m_col.m_bbox.get_width(), m_col.m_bbox.get_top()));
20051991
}
20061992

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

20091998
/* fallen out of the level? */
2010-
if (m_swimming) {
2011-
// If swimming, don't kill; just prevent from falling below the ground
2012-
if ((get_pos().y > Sector::get().get_height() - 1) && (!m_ghost_mode)) {
2013-
set_pos(Vector(get_pos().x, Sector::get().get_height() - 1));
2014-
m_falling_below_water = true;
2015-
}
2016-
} else if ((get_pos().y > Sector::get().get_height()) && (!m_ghost_mode)) {
1999+
if ((get_pos().y > Sector::get().get_height()) && (!m_ghost_mode)) {
20172000
kill(true);
20182001
return;
20192002
}

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)