dimanche 5 novembre 2017

Random boolean for reverse value

Is there a more elegant way to write this code? In my context, I would like to inverse my property easeX but randomly.

   if(Boolean(Math.round(Math.random()))){ obj.easeX = ~obj.easeX+1;};
   if(Boolean(Math.round(Math.random()))){ obj.easeY = ~obj.easeY+1;};

Someone has a better suggestion? Because it is a little heavy for making a simple random reverse. But I can't imagine another cleaner way. I use this code in a update loop.




Aucun commentaire:

Enregistrer un commentaire