# 2D wheel position

This topic is 2874 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, i am new to XNA game Dev. I got through by reading some of the e books and posts and got up to start my first game.

I have a simple roulette wheel which and i am able to rotate the wheel successfully. I also have a small ball that rotates in opposite direction to the wheel.Now my problem is ," how to identify on which value of the wheel(0-36) did the ball stop on". How to identify this ?.
Can some one please guide me through this ?. This would be of immense support to move forward.

##### Share on other sites
Easiest answer is to tackle the problem from reverse. Generate a random value between 0-36 and then make your wheel end up on that particular value. You then know which value the wheel is on (the wheel is just a graphical representation of the generated random number).

Otherwise you would need to determine the number dynamically. The question is really one of mathematics... You know the starting position of the wheel, the length (or at least the force of the turn) which should allow you to easily determine the value at which the wheel will stop (and this very much depends on how you turn your wheel).

In the worst case assuming none of that is possible I assume you could use separate sprites for different parts of the wheel and check collisions but that seems a bit needless in this case.

##### Share on other sites
The other way would be to simply find the angle of the ball position to the wheel center and divide by ( 360 / 37 ). Or depending on your trigonometry functions ( 2 * PI ) / 37.

##### Share on other sites
Thank you!. Will try out the above suggestions..

##### Share on other sites
Hi .. I tried the above solutions, but i have numbers from 0 - 36 arranged randomly on the wheel. I am generating a random number between 0 to 36 and my requirement is to stop the wheel spinning on the the exact number i want ( say number 15 and stop on that). How can i achieve this ?. Please suggest.

Should i use different sprites for each number and check for collision ?.
The wheel i am using more or less looks like the one in the below link, except for the ball i am using it as a separate sprite.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633302
• Total Posts
3011276
• ### Who's Online (See full list)

There are no registered users currently online

×