ok, this is silly... random?

Non-platform specific questions.

ok, this is silly... random?

Postby Kalladdolf » Wed Jan 02, 2008 4:53 pm

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
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

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

Postby makslane » Wed Jan 02, 2008 5:05 pm

Use a code like this:

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


In your case:

Code: Select all
random = -10 + rand(80);
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

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

Postby Kalladdolf » Wed Jan 02, 2008 8:17 pm

kthx, makslane :D
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

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

Postby Bee-Ant » Thu Jan 03, 2008 3:46 pm

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:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

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

Postby Kalladdolf » Sun Jan 06, 2008 6:49 pm

oh, yeah, sure :)
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

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

Postby Bee-Ant » Mon Jan 07, 2008 6:50 am

:roll: :mrgreen:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron