From 0e866f2c8fbd529521dc08aae2bd18a892e26ca3 Mon Sep 17 00:00:00 2001 From: Brockengespenst Date: Mon, 6 May 2024 23:51:25 +0200 Subject: [PATCH 1/4] Do not let unisolid tiles prevent Tux from stand up --- src/collision/collision_system.cpp | 4 ++-- src/collision/collision_system.hpp | 2 +- src/object/player.cpp | 2 +- src/supertux/sector.cpp | 5 +++-- src/supertux/sector.hpp | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/collision/collision_system.cpp b/src/collision/collision_system.cpp index 1d2a4afa5ff..245ec697c8d 100644 --- a/src/collision/collision_system.cpp +++ b/src/collision/collision_system.cpp @@ -726,11 +726,11 @@ CollisionSystem::is_free_of_statics(const Rectf& rect, const CollisionObject* ig } bool -CollisionSystem::is_free_of_movingstatics(const Rectf& rect, const CollisionObject* ignore_object) const +CollisionSystem::is_free_of_movingstatics(const Rectf& rect, const CollisionObject* ignore_object, const bool ignore_unisolid) const { using namespace collision; - if (!is_free_of_tiles(rect)) return false; + if (!is_free_of_tiles(rect, ignore_unisolid)) return false; for (const auto& object : m_objects) { if (object == ignore_object) continue; diff --git a/src/collision/collision_system.hpp b/src/collision/collision_system.hpp index 0dab8149991..82d8104e311 100644 --- a/src/collision/collision_system.hpp +++ b/src/collision/collision_system.hpp @@ -64,7 +64,7 @@ class CollisionSystem final bool is_free_of_tiles(const Rectf& rect, const bool ignoreUnisolid = false, uint32_t tiletype = Tile::SOLID) const; bool is_free_of_statics(const Rectf& rect, const CollisionObject* ignore_object, const bool ignoreUnisolid) const; - bool is_free_of_movingstatics(const Rectf& rect, const CollisionObject* ignore_object) const; + bool is_free_of_movingstatics(const Rectf& rect, const CollisionObject* ignore_object, const bool ignore_unisolid = false) const; bool is_free_of_specifically_movingstatics(const Rectf& rect, const CollisionObject* ignore_object) const; diff --git a/src/object/player.cpp b/src/object/player.cpp index 8d43352d2b3..79d38328113 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -1274,7 +1274,7 @@ Player::do_standup(bool force_standup) { float new_height = m_swimming ? TUX_WIDTH : BIG_TUX_HEIGHT; new_bbox.move(Vector(0, m_col.m_bbox.get_height() - new_height)); new_bbox.set_height(new_height); - if (!Sector::get().is_free_of_movingstatics(new_bbox, this) && !force_standup) + if (!Sector::get().is_free_of_movingstatics(new_bbox, this, true) && !force_standup) { m_crawl = true; return; diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index a9d841ba91f..58fca854696 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -549,10 +549,11 @@ Sector::is_free_of_statics(const Rectf& rect, const MovingObject* ignore_object, } bool -Sector::is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object) const +Sector::is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object, const bool ignore_unisolid) const { return m_collision_system->is_free_of_movingstatics(rect, - ignore_object ? ignore_object->get_collision_object() : nullptr); + ignore_object ? ignore_object->get_collision_object() : nullptr, + ignore_unisolid); } bool diff --git a/src/supertux/sector.hpp b/src/supertux/sector.hpp index a4d342d6c31..e89d33b43cd 100644 --- a/src/supertux/sector.hpp +++ b/src/supertux/sector.hpp @@ -112,7 +112,7 @@ class Sector final : public Base::Sector 1.) solid tiles and 2.) MovingObjects in COLGROUP_STATIC, COLGROUP_MOVINGSTATIC or COLGROUP_MOVING. This includes badguys and players. */ - bool is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object = nullptr) const; + bool is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object = nullptr, const bool ignore_unisolid = false) const; /** Checks if the specified rectangle is free of MovingObjects in COLGROUP_MOVINGSTATIC. Note that this does not include moving badguys, or players */ From 4538d8f037c77a6109717d694e526474838ec998 Mon Sep 17 00:00:00 2001 From: Brockengespenst Date: Mon, 6 May 2024 23:51:52 +0200 Subject: [PATCH 2/4] Consider Tux being on ground if standing on frozen enemy --- src/object/player.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/object/player.cpp b/src/object/player.cpp index 79d38328113..8ce0773c2a7 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -2351,6 +2351,9 @@ Player::collision(GameObject& other, const CollisionHit& hit) return FORCE_MOVE; if (m_stone) return ABORT_MOVE; + + if (hit.bottom && badguy->is_frozen()) + m_on_ground_flag = true; } return CONTINUE; From 7ecee6b63753af12f69370558ef33cc6a280113e Mon Sep 17 00:00:00 2001 From: Brockengespenst Date: Mon, 6 May 2024 23:52:36 +0200 Subject: [PATCH 3/4] Do not change direction of bouncing snowballs due to unisolid tile --- src/badguy/bouncing_snowball.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/badguy/bouncing_snowball.cpp b/src/badguy/bouncing_snowball.cpp index 125a8d3d93e..bc4ea58c283 100644 --- a/src/badguy/bouncing_snowball.cpp +++ b/src/badguy/bouncing_snowball.cpp @@ -66,7 +66,7 @@ BouncingSnowball::active_update(float dt_sec) Rectf side_look_box = get_bbox().grown(-1.f); side_look_box.set_left(get_bbox().get_left() + (m_dir == Direction::LEFT ? -1.f : 1.f)); side_look_box.set_right(get_bbox().get_right() + (m_dir == Direction::LEFT ? -1.f : 1.f)); - if (!Sector::get().is_free_of_statics(side_look_box)) + if (!Sector::get().is_free_of_statics(side_look_box, nullptr, true)) { m_dir = m_dir == Direction::LEFT ? Direction::RIGHT : Direction::LEFT; set_action(m_dir); From 1d7013790e114af847fc2534dd4e0f98a1eaec32 Mon Sep 17 00:00:00 2001 From: Brockengespenst Date: Tue, 7 May 2024 18:05:52 +0200 Subject: [PATCH 4/4] Change PushButton collision goup to static --- src/object/pushbutton.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object/pushbutton.cpp b/src/object/pushbutton.cpp index 9d50f9e5e13..496b0b5dae5 100644 --- a/src/object/pushbutton.cpp +++ b/src/object/pushbutton.cpp @@ -30,7 +30,7 @@ const std::string BUTTON_SOUND = "sounds/switch.ogg"; } PushButton::PushButton(const ReaderMapping& mapping) : - StickyObject(mapping, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_MOVING), + StickyObject(mapping, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_STATIC), m_script(), m_state(OFF), m_dir(Direction::UP)