How to do a roulette?

If you have an overhead view of the roulette wheel and the sprite’s image is circular, then you can rotate the sprite a small amount (such as 1 degree) by setting the sprite’s direction to the sprite’s direction + 1. See these blocks:

And repeat that a random number of times. You’ll want to set a minimum and maximum number of times and you may have to adjust the angular velocity. For example, you wouldn’t want to turn the sprite 4 degrees (random set to 4, turn 1 degree) because it wouldn’t really be noticeable and it wouldn’t be a good visual effect. So maybe start with number >=360.

If you have an arrow or line or other indicator pointing to one part of the circle, then when the sprite stops turning, you determine which number on the roulette wheel was chosen based on what lines up with that arrow. And you calculate it by the starting point of the wheel/sprite and how many turns it made.

It’s sort of like this:

2 Likes