Game Development Reference
In-Depth Information
Listing 12:
Car control script
In lines 6 through 19 we declare few variables related to the car speed, including max
speed of the car
maxSpeed
, increment of the speed with the time
acceleration
, decrement of
the speed with the time
deceleration
, decrement of the speed with the brakes
braking
, and
decrement of the speed when the car turns right or left
turnDeceleration
. All these values
are in km/h, which makes it easy for us to deal with them.