Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created June 15, 2018 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/a0378de53032c85c402f4310b6b149f6 to your computer and use it in GitHub Desktop.
Save ssaurel/a0378de53032c85c402f4310b6b149f6 to your computer and use it in GitHub Desktop.
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