OK, so the basic idea is that you can use sine and cosine to convert from an angle to a position on the screen. If r is the radius, then the (x) and (y) coordinates are r * Math.sin(angle) and r * Math.cos(angle), where angle is measured in radians (so goes from 0 to 2 * PI to complete the circle/ellipse), and where you may need to swap round sin/cos depending on whether you start at 12 o'clock or 3 o'clock. And with an ellipse, your radius actually changes as you go round...
So the idea is that each time the car moves, you nudge the angle on by some random amount and then re-calculate the coordinates.
There's actually a problem with this approach: because the radius of the ellipse varies as you go round, the amount of "real distance" covered by a particular change in angle also varies as you go round. So your cars will appear to move faster at the points where the radius is larger.
A couple of ways round this are to (a) either make the maximum "nudge" vary depending on the radius, or (b) each time calculate a DIRECTION based on a fixed increment to the angle, then calculate a random movement in this direction.
Reputation Points: 120
Solved Threads: 7
Junior Poster in Training
Offline 53 posts
since Dec 2008