# animating roulette ball

I'm trying to achieve something like netent's roulette (which is a great product in my opinion). It's going to be implemented in html5.

I wonder which path should I take to have such a great animation for spinning ball. My problem is that the random number is generated on the server, thus using any of currently available physics engines means loose control of the ball, I mean that it will be hard to apply forces in such a manner that ball hits the right slot. Another option is to make my own a pseudo physics. "Pseudo" because it should always keep track of destination point. It is pretty much like playing animation generated backwards.

-
There are 3 results for 'roulette', excluding the Russian variety, and they were all posted within the last week. Weird. – Seth Battin May 21 '13 at 23:16
P.S., semi-duplicate of gamedev.stackexchange.com/questions/55607/… – Seth Battin May 21 '13 at 23:19
@SethBattin I wonder if someone out there has given a homework assignment... – Steven Stadnicki May 22 '13 at 1:46

Here's a trick to simplify things, based on the fact that all slots are the same size and shape:

1. Run a physics simulation with random input parameters but instead of rendering it just store the ball position and wheel rotation for each frame so you can replay it later.

2. Work out which slot the ball has landed in.

3. Calculate the angle between that slot and the one you actually want it to land in. This will be one of 37 values if there's a single zero on the wheel {0, 360/37 ..., (360*36)/37}.

4. Render the animation sequence you recorded, but with the wheel rotated by that angle from step 3. The ball will now land in the correct slot.

-
Interesting, I'm going to check that. But I'm afraid that any physics engine adds some randomness, tiny deviations. Run this animation jiglibjs.org/demos_official/collisions_similar.htm a few times and you'll see that it's different every time. Thus it wont be possible to "replay" same animations. – harabara May 22 '13 at 6:55
You can replay it in this case very simply - store off the position of the ball and rotation of the wheel every frame during the simulation. The replay uses those stored values rather than re-running the physics simulation. – Adam May 22 '13 at 23:15
ok, i get your point, thank you. i will post here my solution once i have it. – harabara May 23 '13 at 12:43