Skip to content

Fix #2509 : Floating Platform Object Idea #3278

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

goncalof148
Copy link

@goncalof148 goncalof148 commented Jun 7, 2025

The Floating Platform has the following characteristics:

  • Floats on top of water
  • Has a wave-like motion on water
  • Reacts to Tux jumping on it with bubbles and
    a sound effect
  • If not placed on water, behaves like a normal object with
    normal gravity
  • Is placed slightly under water to simulate floating
  • If it has rocks on top, it sinks faster or slower based on
    the number of rocks
  • If it's sinking and the rocks are removed, it floats again

Closes #2509

goncalof148 and others added 2 commits June 6, 2025 13:38
The Floating Platform has the following characteristics:

- Floats on top of water
- Has a wave-like motion on water
- Reacts to Tux jumping on it with bubbles and
a sound effect
- If not placed on water, behaves like a normal object with
normal gravity
- Is placed slightly under water to simulate floating
- If it has rocks on top, it sinks faster or slower based on
the number of rocks
- If it's sinking and the rocks are removed, it floats again

This object was created from scratch. We designed the sprite,
implemented the FloatingPlatform class, and added it to the Level
Editor so players can place it in custom levels.

Co-authored-by: Tomás Correia <tomas.araujo.correia@tecnico.ulisboa.pt>
@tobbi
Copy link
Member

tobbi commented Jun 7, 2025

Can you please fix these compiler errors:

In file included from /home/runner/work/supertux/supertux/src/object/floating_platform.cpp:17:
/home/runner/work/supertux/supertux/src/object/floating_platform.hpp:48:9: error: private field 'm_max_sink_depth' is not used [-Werror,-Wunused-private-field]
  float m_max_sink_depth;
        ^
/home/runner/work/supertux/supertux/src/object/floating_platform.hpp:50:7: error: private field 'number_rocks' is not used [-Werror,-Wunused-private-field]
  int number_rocks;
      ^

Copy link
Member

@bruhmoent bruhmoent left a comment

Choose a reason for hiding this comment

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

Thank you for contributing!

A few notes:

  • I'd recommend using the already existing icefloat (ice floes) sprites instead of introducing a new one,
  • When changing the sprite of the FloatingPlatform, note that splashes aren't created across the full width,
  • When a rock is released from the platform, the platform doesn't go back up,
  • The current behaviour is quite jittery and glitchy, especially in interactions with badguys and the player.

Comment on lines 61 to 68
Vector movement;
if (!m_floating){
movement = m_physic.get_movement(dt_sec) *
Vector(1.f, 1.f);
} else{
movement = m_physic.get_movement(dt_sec) *
Vector(1.f, in_water ? -0.05f : 0.01f);
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Vector movement;
if (!m_floating){
movement = m_physic.get_movement(dt_sec) *
Vector(1.f, 1.f);
} else{
movement = m_physic.get_movement(dt_sec) *
Vector(1.f, in_water ? -0.05f : 0.01f);
}
Vector base_movement = m_physic.get_movement(dt_sec);
Vector movement = m_floating ? base_movement * Vector(1.f, in_water ? -0.05f : 0.01f) : base_movement;

Comment on lines 160 to 163
for (int i = 0; i<10; i++){
Sector::get().add<RainSplash>(Vector(static_cast<float>(get_x()- 5.f + (i*8.f)), static_cast<float>(get_y()+11.f)),
true);
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (int i = 0; i<10; i++){
Sector::get().add<RainSplash>(Vector(static_cast<float>(get_x()- 5.f + (i*8.f)), static_cast<float>(get_y()+11.f)),
true);
}
for (int i = 0; i < 10; i++) {
Sector::get().add<RainSplash>(Vector(get_x() - 5.f + (static_cast<float>(i) * 8.f), get_y() + 11.f),
true);
}

}
m_player_offset = std::min(m_player_offset + sink_speed_player, max_sink_depth_player);
m_physic.set_velocity_y(sink_speed_player);
} else if (!player_check_zone.overlaps(other.get_bbox())){
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} else if (!player_check_zone.overlaps(other.get_bbox())){
} else if (!player_check_zone.overlaps(other.get_bbox())) {

@goncalof148
Copy link
Author

@bruhmoent about the notes, here is a video of what is happening https://www.youtube.com/watch?v=0HYPXKxie-Y
Do you have some different behaviour when rocks are taken of the platform? The player is jittering in what way?
About the other suggestions I am working on them!

@bruhmoent
Copy link
Member

2025-06-21.17-16-18.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Floating Platform Object Idea
3 participants