Right, in my game Traffic Racer I've decided to address the issue of speed. When driving, if I drive slowly at 30 mph at the first line of cars I am at about 100 'meters'. If I put full throttle down at 110 mph I get to like 60 'meters'. These are not accurate, but this is effectively what is happening. Why? How can I stop this?
This is the equation I am currently using:
distance = distance + math.ceil(speed/600)
It is in no terms mathematical, but it adds a distance every wait() so it needs to be a fairly small value hence why it's 600.
Can anyone suggest a sum and wait() period that will keep it constant? So if I go at 30mph for 10 seconds I gain 300 'meters' and if it is 60mph I get 600 'meters'.
Thanks!
v = d/t
That's one of the simplest equation in physics. You're currently doing d = d + v, which is not valid anywhere.
v is 'velocity' or simply 'speed'
Velocity = Distance/Time
You can solve that for each variable in Multiple forms
Distance = Velocity * Time
Time = Distance/Velocity