View Full Version : Yet another noob...
jessejohnson147
Jun 5, 2009, 08:52 PM
What I am trying to achieve is to have a bg image that will randomize when the user clicks the randomize button, but finding a good randomize code that I could use to learn has been hard to come by. Does anyone know any good resources for a random generator code?
Thanks,
BlackWolf
Jun 6, 2009, 06:15 AM
it really all depends how you define "good".
all the numbers you generate will be pseudo-random. getting real random numbers isn't possible with a normal computer as far as I know.
I found the following to be working ... ok ... for me. If you don't need it for some security stuff it should do the trick:
int randomNumber = arc4random()%maximumNumber;
whereas maximum number is ... well ... the maximum you want your random number to be. if you don't need a max just ommit that part and you should get something between 0 and INT_MAX
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.