Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make a roulette board with a ball spinning and landing on a certain field.

The catch is that the field the ball will land on, is known beforehand.

I want the animation to look somewhat realistic, even though the result is decided beforehand. So I think I need to calculate the path the ball will follow, starting from it's end position. However, in this case, it always needs to end up in the same starting position.

How can this be done?

share|improve this question
Is delaying the release of the ball an option? If so, given any wheel speed and ball starting position/velocity you could run the simulation ahead of time to know which fixed time and position the ball would fall. Then it's just a matter of delaying the release of the ball until the number you want will be in the position you want when the ball actually falls which would be an easy calculation. At most the time you would have to wait for the wheel to make 1 rotation at it's initial speed. – WuHoUnited Jun 14 '14 at 16:30
you can add the initial phase where the numbers are too blurred to see and that only ends when it slows down enough for the ball to land in the final hole – ratchet freak Jun 14 '14 at 16:46
In line with my previous comment where the idea is to calculate the final time/position of the ball and then afterwards manipulate the wheel so that the number you want meets it at the same time. Previously I suggested delaying the release of the ball to accomplish this. Another possibility is not delaying the release of the ball, but instead determine the appropriate deceleration of the wheel to make the number meet the ball. – WuHoUnited Jun 14 '14 at 23:30

program your wheel display with a sliding origin. Run the "spin down" algorithm without display, change the origin so the ball will stop on the right number. Run the spin-down algorithm again with display and real time delays.

share|improve this answer

I think you have the right idea - start from the desired end point & work backwards. You have at least 2 variables to play with - the initial speed of the ball & the initial speed of the wheel.

If you want to go nuts with this, remember you also have those diamond-shaped obstacles above the numbers on the wheel. As the ball starts to lose momentum & curve into the numbers, it'll often hit one of those obstacles & take a crazy bounce. That's a place where you can "adjust" the angle of the bounce & make it land where you want.

If you want to keep it simple, always start with the wheel in the same location & just make the (I forget - 34?) possible animations. Playback could be as simple as "show Spin00.gif".

share|improve this answer
37 for a Monte Carlo wheel, 38 for a US wheel. (All wheels have 36 numbers, divided evenly red/black. Monte Carlo wheels have one zero, colored green. US wheels have zero and double-zero green, to increase the house take. The Wikipedia article traces the history, and it is actually quite interesting.) – John R. Strohm Jun 14 '14 at 15:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.