Page 1 of 1

ok, this is silly... random?

PostPosted: Wed Jan 02, 2008 4:53 pm
by Kalladdolf
I have forgot how to make a variable have a random value between two specific numbers (for example between -10 and +80)
:oops:
I once knew it, but I got somehow confused and...
=D

Re: ok, this is silly... random?

PostPosted: Wed Jan 02, 2008 5:05 pm
by makslane
Use a code like this:

Code: Select all
random = minvalue + rand(maxvalue);


In your case:

Code: Select all
random = -10 + rand(80);

Re: ok, this is silly... random?

PostPosted: Wed Jan 02, 2008 8:17 pm
by Kalladdolf
kthx, makslane :D

Re: ok, this is silly... random?

PostPosted: Thu Jan 03, 2008 3:46 pm
by Bee-Ant
Also like this...(if you wanna make random angle between -10 to 80)
Code: Select all
my_angle=rand(90);
angle=-10+my_angle;

it means, if you get 0 of my_angle, your angle would be -10, and if you get 90 of my_angle, your angle would be 80
(just another variation) :mrgreen:

Re: ok, this is silly... random?

PostPosted: Sun Jan 06, 2008 6:49 pm
by Kalladdolf
oh, yeah, sure :)

Re: ok, this is silly... random?

PostPosted: Mon Jan 07, 2008 6:50 am
by Bee-Ant
:roll: :mrgreen: