Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix granito bugs #2797

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a2ae613
Fix granito pushing while sitting
MatusGuy Feb 22, 2024
b19eda0
Merge branch 'SuperTux:master' into granito-fixes
MatusGuy Apr 19, 2024
469e594
fix unable to unduck in granito
MatusGuy Apr 19, 2024
e5ca657
prevent granito being pushed by explosions
MatusGuy Apr 24, 2024
e0f836c
Merge branch 'SuperTux:master' into granito-fixes
MatusGuy Apr 25, 2024
9c1e5aa
fix going up slope with granito
MatusGuy May 11, 2024
1f6c6d9
Merge branch 'granito-fixes' of https://github.com/MatusGuy/supertux …
MatusGuy May 11, 2024
c2d0c6c
Merge branch 'SuperTux:master' into granito-fixes
MatusGuy Jun 26, 2024
36837d0
`Screen`: Virtual methods for SDL and window resize events (#3032)
Vankata453 Aug 7, 2024
fefc0b0
Revenge in Redmond Update (#2662)
Rusty-Box Aug 7, 2024
07d70fc
Merge branch 'real-master' into granito-fixes
MatusGuy Aug 8, 2024
0928a4f
Pass string as const reference in add_option
tobbi Aug 9, 2024
48670aa
i've been lied to
MatusGuy Aug 10, 2024
4aa368f
granito no longer waves when sitting
MatusGuy Aug 10, 2024
a3d18c8
fix rockrolling under granito
MatusGuy Aug 10, 2024
7efcda1
Make "[DISABLED]" translatable (#2980)
Narre Aug 11, 2024
f5535d2
`AmbientSound` now inherits `MovingObject` in scripting
Vankata453 Aug 11, 2024
7aad14c
Squirrel: Fix inaccessible class member variables, improvements (#3031)
Vankata453 Aug 12, 2024
3e0030c
Fix broken tux santa sprite (how did this slip in here)
MatusGuy Aug 13, 2024
2d92941
Error handler: Print fatal exceptions to command line
Vankata453 Aug 15, 2024
eacdc11
Fix Windows compilation after 2d92941
Vankata453 Aug 15, 2024
5260e65
Error handler: Properly print fatal exceptions to command line
Vankata453 Aug 15, 2024
aee3fc7
Add more convenience functions to Player class (#3037)
tobbi Aug 15, 2024
f432274
Revert "Generate builds with `RelWithDebInfo` instead of `Release` (#…
Semphriss Aug 18, 2024
c39b073
Update translations
SuperTux-bot Aug 19, 2024
6376c05
Update translations
SuperTux-bot Aug 22, 2024
38f5005
Merge branch 'real-master' into granito-fixes
MatusGuy Aug 29, 2024
a7f76a7
granito look up btw im going insane
MatusGuy Aug 31, 2024
9d7b452
play falling animation
MatusGuy Aug 31, 2024
5d9ea51
WIP!!!!!!!!!!
MatusGuy Sep 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/badguy/badguy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class BadGuy : public MovingSprite,

bool is_in_water() const;

virtual bool is_heavy() const { return false; }

/** Get melting particle sprite filename */
virtual std::string get_water_sprite() const {
return "images/objects/water_drop/water_drop.sprite";
Expand Down
13 changes: 6 additions & 7 deletions src/badguy/granito.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Granito::Granito(const ReaderMapping& reader, const std::string& sprite_name, in
parse_type(reader);

walk_speed = 0;
max_drop_height = 600;
set_ledge_behavior(LedgeBehavior::NORMAL);

m_countMe = false;

Expand Down Expand Up @@ -215,7 +215,8 @@ Granito::collision(GameObject& other, const CollisionHit& hit)

if (hit.bottom)
{
if (m_state == STATE_SIT) return WalkingBadguy::collision(other, hit);
if (m_state == STATE_SIT)
return WalkingBadguy::collision(other, hit);

// Yo big granito can i sit on top of your head?
GranitoBig* granito = dynamic_cast<GranitoBig*>(&other);
Expand All @@ -240,7 +241,7 @@ Granito::collision(GameObject& other, const CollisionHit& hit)
Sector::get().run_script(m_carried_script, "carried-script");
}

return WalkingBadguy::collision(other, hit);
return FORCE_MOVE;
}

void
Expand Down Expand Up @@ -330,13 +331,11 @@ Granito::initialize()

if (m_type == WALK)
{
m_original_state = STATE_WALK;
restore_original_state();
walk();
}
else if (m_type == SIT)
{
m_original_state = STATE_SIT;
restore_original_state();
sit();
}

switch (m_type)
Expand Down
1 change: 1 addition & 0 deletions src/badguy/granito.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Granito : public WalkingBadguy
virtual bool is_snipable() const override { return false; }
virtual bool is_freezable() const override { return false; }
virtual bool is_flammable() const override { return false; }
virtual bool is_heavy() const override { return true; }

virtual void kill_fall() override;

Expand Down
1 change: 1 addition & 0 deletions src/badguy/granito_big.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ GranitoBig::GranitoBig(const ReaderMapping& reader) :
m_carrying(nullptr)
{
parse_type(reader);
set_ledge_behavior(LedgeBehavior::SMART);

reader.get("carrying-script", m_carried_script);

Expand Down
2 changes: 1 addition & 1 deletion src/badguy/granito_giant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GranitoGiant::GranitoGiant(const ReaderMapping& reader):
}

HitResponse
GranitoGiant::collision_player(Player &player, const CollisionHit &hit)
GranitoGiant::collision(GameObject& other, const CollisionHit& hit)
{
return FORCE_MOVE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/badguy/granito_giant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GranitoGiant final : public BadGuy
public:
explicit GranitoGiant(const ReaderMapping& reader);

virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
virtual void initialize() override;

static std::string class_name() { return "granito_giant"; }
Expand Down
9 changes: 6 additions & 3 deletions src/collision/collision_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ collision::Constraints check_collisions(const Vector& obj_movement, const Rectf&
if (other_object && other_object->is_unisolid())
{
// Constrain only on fall on top of the unisolid object.
if (moving_obj_rect.get_bottom() - obj_movement.y <= grown_other_obj_rect.get_top())
// Here we are checking the movements of the objects to prevent
// overshoot if both objects are going in convergent directions
if (moving_obj_rect.get_bottom() - obj_movement.y <= grown_other_obj_rect.get_top() - (other_object->get_movement().y - 5.f))
{
constraints.constrain_bottom(other_obj_rect.get_top());
constraints.hit.bottom = true;
Expand Down Expand Up @@ -726,15 +728,16 @@ 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 ignoreUnisolid) const
{
using namespace collision;

if (!is_free_of_tiles(rect)) return false;
if (!is_free_of_tiles(rect, ignoreUnisolid)) return false;

for (const auto& object : m_objects) {
if (object == ignore_object) continue;
if (!object->is_valid()) continue;
if (object->is_unisolid() && ignoreUnisolid) continue;
if ((object->get_group() == COLGROUP_MOVING)
|| (object->get_group() == COLGROUP_MOVING_STATIC)
|| (object->get_group() == COLGROUP_STATIC)) {
Expand Down
2 changes: 1 addition & 1 deletion src/collision/collision_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ignoreUnisolid) const;
bool is_free_of_specifically_movingstatics(const Rectf& rect, const CollisionObject* ignore_object) const;


Expand Down
2 changes: 1 addition & 1 deletion src/object/explosion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Explosion::explode()
}

auto badguy = dynamic_cast<WalkingBadguy*>(obj);
if (badguy && badguy->is_active()) {
if (badguy && badguy->is_active() && !badguy->is_heavy()) {
badguy->add_velocity(add_speed);
}

Expand Down
2 changes: 1 addition & 1 deletion src/object/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,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;
Expand Down
7 changes: 4 additions & 3 deletions src/supertux/sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,16 +566,17 @@ Sector::is_free_of_statics(float left, float top, float right, float bottom,
}

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 ignoreUnisolid) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style: Please name the variable ignore_unisolid

{
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,
ignoreUnisolid);
}

bool
Sector::is_free_of_movingstatics(float left, float top, float right, float bottom) const
{
return m_collision_system->is_free_of_movingstatics(Rectf(Vector(left, top), Vector(right, bottom)), nullptr);
return m_collision_system->is_free_of_movingstatics(Rectf(Vector(left, top), Vector(right, bottom)), nullptr, false);
}

bool
Expand Down
2 changes: 1 addition & 1 deletion src/supertux/sector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,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 ignoreUnisolid = false) const;
/**
* @scripting
* @description Checks if the specified sector-relative rectangle is free of both:
Expand Down
Loading