Slow down steering at higher speeds

This commit is contained in:
Miloslav Ciz 2025-03-30 20:29:35 +02:00
parent 9a4d49d7e6
commit fb5d9d118e
3 changed files with 15 additions and 83 deletions

View file

@ -76,7 +76,8 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
#define LCR_CAR_STEER_FRICTION ((3 * TPE_F) / 4)
#define LCR_CAR_ELASTICITY (TPE_F / 64)
#define LCR_CAR_ACCELERATION (LCR_PHYSICS_UNIT / 9)
#define LCR_CAR_STEER_SPEED 13 ///< 0 to 16, lower is faster
#define LCR_CAR_STEER_SPEED 52 ///< 0 to 64, lower is faster
#define LCR_CAR_STEER_SLOWDOWN 128 ///< slows down steering at higher speeds
#define LCR_CAR_STEER_MAX (LCR_GAME_UNIT / 2)
#define LCR_CAR_ACCELERATOR_FACTOR 2
@ -1290,17 +1291,20 @@ uint32_t LCR_racingStep(unsigned int input)
{
steering = 2;
LCR_racing.wheelSteer =
LCR_CAR_STEER_MAX -
(LCR_CAR_STEER_SPEED * (LCR_CAR_STEER_MAX - LCR_racing.wheelSteer)) / 16;
// We slow down steering by 1 for each LCR_CAR_STEER_SLOWDOWN speed.
LCR_racing.wheelSteer = LCR_CAR_STEER_MAX -
(TPE_min(LCR_CAR_STEER_SPEED + LCR_racingGetCarSpeedUnsigned() /
LCR_CAR_STEER_SLOWDOWN,64) * (LCR_CAR_STEER_MAX -
LCR_racing.wheelSteer)) / 64;
}
else if (input & LCR_RACING_INPUT_LEFT)
{
steering = 1;
LCR_racing.wheelSteer =
-1 * LCR_CAR_STEER_MAX +
(LCR_CAR_STEER_SPEED * (LCR_racing.wheelSteer + LCR_CAR_STEER_MAX)) / 16;
LCR_racing.wheelSteer = -1 * LCR_CAR_STEER_MAX +
(TPE_min(LCR_CAR_STEER_SPEED + LCR_racingGetCarSpeedUnsigned() /
LCR_CAR_STEER_SLOWDOWN,64) * (LCR_racing.wheelSteer +
LCR_CAR_STEER_MAX)) / 64;
}
if ((LCR_racing.wheelCollisions & 0xcc)) // back wheel on ground?