Skip to content

Commit

Permalink
Prevent igel weird freeze behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusGuy committed Dec 22, 2023
1 parent 293d6ac commit 96682c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/badguy/igel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ void
Igel::active_update(float dt_sec)
{
WalkingBadguy::active_update(dt_sec);

if (m_frozen) return;

switch (m_state)
{
case STATE_ROLLING:
Expand Down Expand Up @@ -160,6 +163,26 @@ Igel::run_dead_script()
WalkingBadguy::run_dead_script();
}

void
Igel::unfreeze(bool melt)
{
WalkingBadguy::unfreeze(melt);

if (melt) return;

m_state = STATE_NORMAL;
m_bonked = false;

set_action(m_dir);

float vel = get_normal_walk_speed();
set_walk_speed(vel);
m_physic.set_velocity_x(vel * (m_dir == Direction::LEFT ? -1 : 1));

m_roll_timer.stop();
m_ease_timer.stop();
}

GameObjectTypes
Igel::get_types() const
{
Expand Down
1 change: 1 addition & 0 deletions src/badguy/igel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Igel final : public WalkingBadguy
virtual std::string get_display_name() const override { return display_name(); }

virtual bool is_freezable() const override { return true; }
virtual void unfreeze(bool melt = true) override;

virtual GameObjectTypes get_types() const override;
virtual std::string get_default_sprite_name() const override;
Expand Down

0 comments on commit 96682c1

Please sign in to comment.