Add gradual steering

This commit is contained in:
Miloslav Ciz 2025-03-27 15:28:48 +01:00
parent c992ddeb3f
commit 252bf57e41
4 changed files with 21 additions and 9 deletions

View file

@ -76,7 +76,7 @@ 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 (LCR_GAME_UNIT / 14)
#define LCR_CAR_STEER_SPEED 13 ///< 0 to 16, lower is faster
#define LCR_CAR_STEER_MAX (LCR_GAME_UNIT / 2)
#define LCR_CAR_ACCELERATOR_FACTOR 2
@ -1289,24 +1289,24 @@ uint32_t LCR_racingStep(unsigned int input)
if (input & LCR_RACING_INPUT_RIGHT)
{
steering = 2;
LCR_racing.wheelSteer = TPE_min(
LCR_racing.wheelSteer + LCR_CAR_STEER_SPEED,
LCR_CAR_STEER_MAX);
LCR_racing.wheelSteer =
LCR_CAR_STEER_MAX -
(LCR_CAR_STEER_SPEED * (LCR_CAR_STEER_MAX - LCR_racing.wheelSteer)) / 16;
}
else if (input & LCR_RACING_INPUT_LEFT)
{
steering = 1;
LCR_racing.wheelSteer = TPE_max(
LCR_racing.wheelSteer - LCR_CAR_STEER_SPEED,
-1 * LCR_CAR_STEER_MAX);
LCR_racing.wheelSteer =
-1 * LCR_CAR_STEER_MAX +
(LCR_CAR_STEER_SPEED * (LCR_racing.wheelSteer + LCR_CAR_STEER_MAX)) / 16;
}
if ((LCR_racing.wheelCollisions & 0xcc)) // back wheel on ground?
{
if (input & LCR_RACING_INPUT_FORW)
{
{
_LCR_racingWheelAccelerate(0,carForw,groundMat,onAccel);
_LCR_racingWheelAccelerate(1,carForw,groundMat,onAccel);
}