Continue crash sound

This commit is contained in:
Miloslav Ciz 2024-12-27 07:45:27 +01:00
parent b90f5bbfc8
commit 85b8b1352d
3 changed files with 65 additions and 64 deletions

View file

@ -45,7 +45,10 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
#define LCR_CAR_DRIFT_THRESHOLD_1 (LCR_GAME_UNIT / 4)
#define LCR_CAR_DRIFT_THRESHOLD_0 (LCR_GAME_UNIT / 200)
#define LCR_CAR_CRASH_SPEED_THRESHOLD 25
#define LCR_CAR_CRASH_SPEED_DIFF 25
#define LCR_CAR_CRASH_SPEED_THRESHOLD 70
// multipliers (in 8ths) of friction and acceleration on concrete:
#define LCR_CAR_GRASS_FACTOR 5
@ -1077,7 +1080,9 @@ uint32_t LCR_racingStep(unsigned int input)
TPE_worldStep(&(LCR_racing.physicsWorld));
LCR_LOG2("stepping physics engine done");
int speedDiff = LCR_racing.carSpeeds[0] - LCR_racing.carSpeeds[1];
int speedDiff =
TPE_abs(LCR_racing.carSpeeds[0]) -
TPE_abs(LCR_racing.carSpeeds[1]);
LCR_racing.carSpeeds[1] = LCR_racing.carSpeeds[0];
@ -1087,14 +1092,11 @@ uint32_t LCR_racingStep(unsigned int input)
if (TPE_vec3Dot(carVel,carForw) < 0)
LCR_racing.carSpeeds[0] *= -1;
else if (speedDiff < -1 * LCR_CAR_CRASH_SPEED_THRESHOLD)
{
result |= (speedDiff < -2 * LCR_CAR_CRASH_SPEED_THRESHOLD) ?
if (speedDiff < -1 * LCR_CAR_CRASH_SPEED_DIFF &&
TPE_abs(LCR_racing.carSpeeds[0]) <= LCR_CAR_CRASH_SPEED_THRESHOLD)
result |= (speedDiff < -2 * LCR_CAR_CRASH_SPEED_DIFF) ?
LCR_RACING_EVENT_CRASH_BIG : LCR_RACING_EVENT_CRASH_SMALL;
LCR_racing.carSpeeds[1] = 0; // prevent several crash events in a row
}
_LCR_racingUpdateCarPosRot();
TPE_Unit angle = TPE_vec3Dot(carUp,TPE_vec3Normalized(TPE_vec3Minus(