Skip to content

Commit

Permalink
Remove the ignore horizontal crush member
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusGuy committed Dec 7, 2024
1 parent 6db5648 commit d10fc53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
15 changes: 6 additions & 9 deletions src/badguy/crusher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,18 @@ Crusher::collision(GameObject& other, const CollisionHit& hit)

// If the other object is the player, and the collision is at the
// bottom of the crusher, hurt the player.
if (player && is_crushing &&
((crushed_bottom && player->on_ground()) || crushed_sideways)) {
if (player && is_crushing &&
((crushed_bottom && player->on_ground()) || crushed_sideways))
{
SoundManager::current()->play("sounds/brick.wav", get_pos());
set_state(RECOVERING);

if (player->is_invincible()) {
return ABORT_MOVE;
}
if(crushed_sideways)
{
// TODO: Is there a better method than introducing
// a completely new player method (e.g. by returning
// ABORT_MOVE from this function)?
player->ignore_sideways_crush();
}

player->kill(false);

return FORCE_MOVE;
}

Expand Down
16 changes: 2 additions & 14 deletions src/object/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ Player::Player(PlayerStatus& player_status, const std::string& name_, int player
m_jump_early_apex(false),
m_on_ice(false),
m_ice_this_frame(false),
m_ignore_sideways_crush(false),
//m_santahatsprite(SpriteManager::current()->create("images/creatures/tux/santahat.sprite")),
m_multiplayer_arrow(SpriteManager::current()->create("images/engine/hud/arrowdown.png")),
m_tag_timer(),
Expand Down Expand Up @@ -2323,19 +2322,8 @@ Player::collision_solid(const CollisionHit& hit)
m_physic.set_velocity_x(0);
}

// crushed?
if (hit.crush) {
if ((hit.left || hit.right)) {
if (m_ignore_sideways_crush) {
m_ignore_sideways_crush = false;
}
else {
kill(true);
}
} else if (hit.top || hit.bottom) {
kill(false);
}
}
if (hit.crush)
kill(false);

if ((hit.left && m_boost < 0.f) || (hit.right && m_boost > 0.f))
m_boost = 0.f;
Expand Down
2 changes: 0 additions & 2 deletions src/object/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ class Player final : public MovingObject
void remove_collected_key(Key* key);

bool track_state() const override { return false; }
void ignore_sideways_crush() { m_ignore_sideways_crush = true; }

private:
void handle_input();
Expand Down Expand Up @@ -501,7 +500,6 @@ class Player final : public MovingObject
bool m_jump_early_apex;
bool m_on_ice;
bool m_ice_this_frame;
bool m_ignore_sideways_crush;
//SpritePtr m_santahatsprite;
SpritePtr m_multiplayer_arrow;

Expand Down

0 comments on commit d10fc53

Please sign in to comment.