samedi 24 janvier 2015

How to fix random code to always stop at a specific degree

I have an android app that is a random spinner with a small grey spot. When you click on the spinner it will spin clockwise a certain amount of degrees. There is a pointer on the top, where if the pointer lands on the grey spot you win. I have the code I used but I'm doing some testing. So how would I change the numbers in my code so that it always lands on the grey spot?


Also the grey spot is on the 14 degree mark.



var deg = 12 * 360;
if(onWin) {
deg-=7;
deg+=(Math.random()*14);
} else {
deg=deg+8+(Math.random()*344);
}




Aucun commentaire:

Enregistrer un commentaire