Skip to content

Commit 6f41c8e

Browse files
committed
player: Fix tux clipping thru floor after damage while idle
Well, just his sprite. Seen with granitos, but you can test on conveyor belts and hit a saw or something Signed-off-by: Swagtoy <me@ow.swag.toys>
1 parent 0bd8209 commit 6f41c8e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/object/player.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
const float TUX_INVINCIBLE_TIME_WARNING = 2.0f;
5656

57-
namespace
57+
namespace
5858
{
5959
/* Times: */
6060
const float TUX_SAFE_TIME = 1.8f;
@@ -267,7 +267,7 @@ Player::Player(PlayerStatus& player_status, const std::string& name_, int player
267267

268268
m_col.set_size(TUX_WIDTH, is_big() ? BIG_TUX_HEIGHT : SMALL_TUX_HEIGHT);
269269

270-
270+
271271
m_sprite->set_angle(0.0f);
272272
//m_santahatsprite->set_angle(0.0f);
273273

@@ -2198,7 +2198,7 @@ Player::draw(DrawingContext& context)
21982198
const bool is_not_idle = std::all_of(IDLE_STAGES.begin(), IDLE_STAGES.end(),
21992199
[this](const std::string& stage) { return m_sprite->get_action().find("-" + stage + "-") == std::string::npos; });
22002200

2201-
if (is_not_idle || (m_should_fancy_idle && !m_fancy_idle_active))
2201+
if (is_not_idle || (m_should_fancy_idle && !m_fancy_idle_active) || m_reset_action)
22022202
{
22032203
m_idle_stage = 0;
22042204
m_idle_timer.start(static_cast<float>(TIME_UNTIL_IDLE) / 1000.0f);
@@ -2211,6 +2211,9 @@ Player::draw(DrawingContext& context)
22112211
}
22122212
else
22132213
m_fancy_idle_active = true;
2214+
2215+
if (m_reset_action)
2216+
m_reset_action = false;
22142217
}
22152218
else if (m_should_fancy_idle)
22162219
{
@@ -2487,6 +2490,7 @@ Player::kill(bool completely)
24872490

24882491
if (!completely && is_big()) {
24892492
SoundManager::current()->play("sounds/hurt.wav", get_pos());
2493+
m_reset_action = true;
24902494

24912495
if (get_bonus() > BONUS_GROWUP)
24922496
{

src/object/player.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class Player final : public MovingSprite
394394
/**
395395
* @scripting
396396
* @description Enables Tux's fancy idle animations.
397-
*/
397+
*/
398398
inline void enable_fancy_idling() { m_should_fancy_idle = true; }
399399
/**
400400
* @scripting
@@ -627,6 +627,7 @@ class Player final : public MovingSprite
627627

628628
bool m_should_fancy_idle;
629629
bool m_fancy_idle_active;
630+
bool m_reset_action; /**< Attempts to reset tux back to the initial idle state */
630631

631632
Vector m_floor_normal;
632633

0 commit comments

Comments
 (0)