supertux
supertux copied to clipboard
Tux sliding on belly sprite should be orientated to fit the angle of the slope they're sliding down
13 seconds into the SuperTux: Development Summary of 2023! we see Tux stay perfectly horizontal on a slope while sliding rather than diagonally.
Dependent on (https://github.com/SuperTux/supertux/issues/1448)
Dependent on (#1448)
The sprite isn't dependent on the hitbox.
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.
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.
Fuck yeah, this is already more awesome than what we have in the game.
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.
THIS IS PEAK
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
there should also be particle effects depending on the environment!