mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Loops: try to position player so hitbox edge touches loop radius
Large enough momentum will still position the player beyond the loop radius initially. This is intentional so that there is no jerk when entering the loop. Without a more sophisticated algorithm to revolve asymmetrically, this is the best I can do. The player is guaranteed to exit at the correct position, though.
This commit is contained in:
parent
2c1cce17b2
commit
c87ffeba29
2 changed files with 16 additions and 3 deletions
|
|
@ -7847,6 +7847,15 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
|
|||
player->mo->sprzoff += player->cameraOffset;
|
||||
}
|
||||
|
||||
if (player->loop.radius)
|
||||
{
|
||||
// Offset sprite Z position so wheels touch top of
|
||||
// hitbox when rotated 180 degrees.
|
||||
// TODO: this should be generalized for pitch/roll
|
||||
angle_t pitch = FixedAngle(player->loop.revolution * 360) / 2;
|
||||
player->mo->sprzoff += FixedMul(player->mo->height, FSIN(pitch));
|
||||
}
|
||||
|
||||
K_UpdateOffroad(player);
|
||||
K_UpdateDraft(player);
|
||||
K_UpdateEngineSounds(player); // Thanks, VAda!
|
||||
|
|
|
|||
10
src/p_loop.c
10
src/p_loop.c
|
|
@ -96,7 +96,7 @@ boolean P_PlayerOrbit(player_t *player)
|
|||
angle_t pitch;
|
||||
angle_t pitch_normal;
|
||||
|
||||
fixed_t xy, z;
|
||||
fixed_t r, xy, z;
|
||||
fixed_t xs, ys;
|
||||
|
||||
fixed_t step, th, left;
|
||||
|
|
@ -124,9 +124,13 @@ boolean P_PlayerOrbit(player_t *player)
|
|||
pitch = get_pitch(s->revolution);
|
||||
pitch_normal = get_pitch(normal_revolution(s) / 2);
|
||||
|
||||
r = abs(s->radius) -
|
||||
FixedMul(player->mo->radius, abs(FSIN(pitch)));
|
||||
|
||||
xy = FixedMul(abs(s->radius), FSIN(pitch));
|
||||
z = FixedMul(abs(s->radius), -(FCOS(pitch)));
|
||||
xy = FixedMul(r, FSIN(pitch));
|
||||
|
||||
z = FixedMul(abs(s->radius), -(FCOS(pitch))) -
|
||||
FixedMul(player->mo->height, FSIN(pitch / 2));
|
||||
|
||||
// XY shift is transformed on wave scale; less movement
|
||||
// at start and end of rotation, more halfway.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue