five-on-it / apps/client/src/renderer/camera-shake
apps/client/src/renderer/camera-shake
The camera's shake when something blows up near the player, or the player's car crashes: a blast adds a jolt as big as the blast and as near as it is to where the camera looks (jolt), a crash one by the hit points it took (IMPACT_POINTS_PER_METRE), the jolts add up to a most (MAX_SHAKE), and the shake dies away in about half a second. The offset it puts on the camera's eye and target (ShakeOffset) wobbles on three fixed frequencies, so it never looks like the same shake twice and needs no random numbers.