supertux icon indicating copy to clipboard operation
supertux copied to clipboard

Tux sliding on belly sprite should be orientated to fit the angle of the slope they're sliding down

Open RustoMCSpit opened this issue 1 year ago • 9 comments

13 seconds into the SuperTux: Development Summary of 2023! we see Tux stay perfectly horizontal on a slope while sliding rather than diagonally.

RustoMCSpit avatar Jan 01 '24 02:01 RustoMCSpit

Dependent on (https://github.com/SuperTux/supertux/issues/1448)

RustoMCSpit avatar Jan 01 '24 02:01 RustoMCSpit

Dependent on (#1448)

The sprite isn't dependent on the hitbox.

bruhmoent avatar Jan 01 '24 02:01 bruhmoent

This would also requires smooth transitioning / blending between orientations which are impacted by velocity / acceleration. This could be done via interpolation, easing, dynamic effect (blender animation suite terminology) and by plugging in the variables.

RustoMCSpit avatar Jan 01 '24 02:01 RustoMCSpit

If it is just about simply rotating the sprite, this can be achieved by placing

if (m_sliding)
{
  float sprite_angle = 0.0f;
  if (m_floor_normal.y != 0.0f)
  {
   sprite_angle = math::degrees(math::angle(m_floor_normal)) + 90.0f;
 }
 m_sprite->set_angle(sprite_angle);
}

Around line 1436 in player.cpp (probably also other places possible). The result would be the following:

https://github.com/SuperTux/supertux/assets/155102424/b2f54dd8-b942-451b-a425-c83312bdbf85

This would not rotate the hitbox, just the sprite of Tux. It also does not include a "smooth transition" right now, which is most likely a bit more complex to implement.

If the above behavior would be Ok as a first step, I could create a PR if you like.

Brockengespenst avatar Feb 03 '24 13:02 Brockengespenst

Fuck yeah, this is already more awesome than what we have in the game.

tobbi avatar Feb 03 '24 14:02 tobbi

I created a PR that, additionally to the above mentioned changes, also uses Tux' velocity for sprite orientation in case you jump off an edge while sliding.

Brockengespenst avatar Feb 03 '24 14:02 Brockengespenst

THIS IS PEAK

Frostwithasideofsalt avatar Feb 03 '24 19:02 Frostwithasideofsalt

Supertux-Sliding-Angle.mp4

hold om this gives me a genius idea. we can have level design based on this new mechanic where tux has to slide to generate momentum and then fly off an edge to get over a gap like in https://apps.apple.com/gb/app/racing-penguin-slide-and-fly/id443637419

RustoMCSpit avatar Feb 04 '24 01:02 RustoMCSpit

there should also be particle effects depending on the environment!

RustoMCSpit avatar Feb 04 '24 01:02 RustoMCSpit