Skip to content

Commit

Permalink
Earth powerup stone form breaks bricks below without stopping (SuperT…
Browse files Browse the repository at this point in the history
…ux#2535)

This should close SuperTux#2532
  • Loading branch information
MatusGuy committed Jul 20, 2023
1 parent 6339005 commit 36365cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
13 changes: 2 additions & 11 deletions src/object/brick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ HitResponse
Brick::collision(GameObject& other, const CollisionHit& hit)
{
auto player = dynamic_cast<Player*> (&other);
if (player) {
if (player->m_does_buttjump) try_break(player);
if (player->is_stone() && player->get_velocity().y >= 280) try_break(player); // stoneform breaks through bricks
}
if (player && player->m_does_buttjump) try_break(player);

auto badguy = dynamic_cast<BadGuy*> (&other);
if (badguy) {
Expand Down Expand Up @@ -166,13 +163,7 @@ HitResponse
HeavyBrick::collision(GameObject& other, const CollisionHit& hit)
{
auto player = dynamic_cast<Player*>(&other);
if (player)
{
if (player->is_stone() && player->get_velocity().y >= 280)
try_break(player);
else if (player->m_does_buttjump)
ricochet(&other);
}
if (player && player->m_does_buttjump) ricochet(&other);

auto crusher = dynamic_cast<Crusher*> (&other);
if (crusher)
Expand Down
20 changes: 15 additions & 5 deletions src/object/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,19 +745,29 @@ Player::update(float dt_sec)
}
}

if (m_does_buttjump)
if (m_does_buttjump || (m_stone && m_physic.get_velocity_y() > 30.f && !m_coyote_timer.started()))
{
Rectf downbox = get_bbox().grown(-1.f);
downbox.set_bottom(get_bbox().get_bottom() + 16.f);
for (auto& brick : Sector::get().get_objects_by_type<Brick>()) {
if (downbox.contains(brick.get_bbox()) && brick.get_class_name() != "heavy-brick") {
// stoneform breaks through any kind of bricks
if (downbox.contains(brick.get_bbox()) && (m_stone || !dynamic_cast<HeavyBrick*>(&brick)))
brick.try_break(this, is_big());
}
}
for (auto& badguy : Sector::get().get_objects_by_type<BadGuy>()) {
if (downbox.contains(badguy.get_bbox()) && badguy.is_snipable()) {
if (downbox.contains(badguy.get_bbox()) && badguy.is_snipable())
badguy.kill_fall();
}
}
}

// break bricks above without stopping
if (m_stone && m_physic.get_velocity_y() < 30.f)
{
Rectf topbox = get_bbox().grown(-1.f);
topbox.set_top(get_bbox().get_top() - 16.f);
for (auto& brick : Sector::get().get_objects_by_type<Brick>()) {
if (topbox.contains(brick.get_bbox()))
brick.try_break(this, is_big());
}
}

Expand Down

0 comments on commit 36365cd

Please sign in to comment.