SuperTux / supertux

SuperTux source code
https://supertux.org
GNU General Public License v3.0
2.49k stars 471 forks source link

Tux emits bubbles while being underwater #3014

Open bruhmoent opened 1 month ago

bruhmoent commented 1 month ago

This pr adds a visual effect - when Tux is underwater, he will emit bubble particles that will follow a sine pattern until they reach the water surface.

Make sure to test.

Brockengespenst commented 1 month ago

I think this is a pretty nice feature, but is it possible that the air_bubble-*.png files are missing? Maybe some idea: What about using std::array for m_bubble_particles? This would make it easier to iterate over the array or do a check for bounds (e.g. when picking a random bubble).

bruhmoent commented 1 month ago

Oh you're right, I forgot to push the bubbles.

Brockengespenst commented 1 month ago

Looks pretty nice so far. Some comments from my side:

bruhmoent commented 1 month ago

I like the effect of them "popping" in the air. And for the bubbles not being emitted at the right place, I'm aware - but I don't know what to do about it - sometimes the sprite rotation gets registered improperly - At-least that's what I've observed.

Brockengespenst commented 1 month ago

Some suggestions:

bruhmoent commented 1 month ago

Thanks for the suggestions!

Brockengespenst commented 1 month ago

No problem. I really like this feature, but I think there are two small tweaks to be done:

It would be great if you could have a look at these two things.

Rusty-Box commented 1 month ago

@bruhmoent Why did you not use the .sprite file I send you?

Rusty-Box commented 1 month ago

Also, I think the bubbles vertical speed could be increased by quite a bit

bruhmoent commented 1 month ago

@bruhmoent Why did you not use the .sprite file I send you?

I just used the images - I found the .sprite file to be unnecessary? Idk how does it matter really

Brockengespenst commented 1 month ago

Sorry, but I have to slightly update my suggestion regarding how to determine the direction. From the swim sprite logic, I saw that the following code is used: std::abs(m_swimming_angle) <= math::PI_2 ? Direction::RIGHT : Direction::LEFT This seems to work more reliable, because it takes also negative angles into account.

mstoeckl commented 1 month ago

While this looks nice and cartoony, I (random passerby) should warn that cartoons are often wrong, and actual penguins probably don't breathe out underwater. (Nor should any species that can't breathe in underwater, except if very close to the surface :-)

Instead of emitting periodic bubbles from their beaks, penguins might produce them through:

  1. splashing near water surface
  2. possible: some bubbles when opening beak underwater to grab things for the first time
  3. releasing trapped air after diving in (looks like many small trailing bubbles from the back/wings of penguin; could take some time for all bubbles to go.)

Therefore: I would suggest emitting the bubbles more irregularly in space and time; from the main body instead of from the beak; and maybe progressively reduce the bubble rate the longer Tux stays underwater.

bruhmoent commented 1 month ago

SuperTux is not aimed to replicate realistic behaviours. This is just a little visual effect. This is out of scope for this PR - and this might be adjusted in the future.

mstoeckl commented 1 month ago

SuperTux is not aimed to replicate realistic behaviours. This is just a little visual effect. This is out of scope for this PR - and this might be adjusted in the future.

Agreed. While I think foundations in reality are nice to have, in the end art and gameplay are what matter.

Rusty-Box commented 2 weeks ago

The bubbles are still not animated despite the sprite file having 2 action of animation. One for bigger bubbles and one for smaller ones.