Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get the text pointed by the ball on the wheel for the Roulette Game on the SSaurel's Channel
private String getSector(int degrees) {
int i = 0;
String text = null;
do {
// start and end of each sector on the wheel
float start = HALF_SECTOR * (i * 2 + 1);
float end = HALF_SECTOR * (i * 2 + 3);
if (degrees >= start && degrees < end) {
// degrees is in [start;end[
// so text is equals to sectors[i];
text = sectors[i];
}
i++;
// now we can test our Android Roulette Game :)
// That's all !
// In the second part, you will learn how to add some bets on the table to play to the Roulette Game :)
// Subscribe and stay tuned !
} while (text == null && i < sectors.length);
return text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment