random

Game Editor comments and discussion.

random

Postby yep » Fri Mar 25, 2005 6:19 am

how random works in GE?
sup?
yep
 
Posts: 15
Joined: Thu Mar 24, 2005 6:28 pm
Score: 0 Give a positive score

Postby Just4Fun » Fri Mar 25, 2005 6:53 am

yep:
Your best bet is to search the forum using "random" or "rand" as your search term. There are a number of threads that discuss randomizing. The code depends somewhat on what you are trying to accomplish in your program.

If you are pretty comfortable with the c scripting, you might want to take a look in the demo section and download "Fortune Cookie Sooth" The program uses the rand() function to generate different fortunes. HTHs
I've learned that I still have a lot to learn.

** Makslane == Genious **
Just4Fun
 
Posts: 524
Joined: Tue Jul 01, 2003 5:19 am
Location: USA: Washington State; West Coast
Score: 6 Give a positive score

Postby yep » Fri Mar 25, 2005 7:16 am

Just4Fun wrote:yep:
Your best bet is to search the forum using "random" or "rand" as your search term. There are a number of threads that discuss randomizing. The code depends somewhat on what you are trying to accomplish in your program.

If you are pretty comfortable with the c scripting, you might want to take a look in the demo section and download "Fortune Cookie Sooth" The program uses the rand() function to generate different fortunes. HTHs


let me test here...but is the rand(1) a number being generate from 0 to 1?
sup?
yep
 
Posts: 15
Joined: Thu Mar 24, 2005 6:28 pm
Score: 0 Give a positive score

Postby Just4Fun » Sat Mar 26, 2005 2:28 am

As stated in the documentation:
C syntax for rand:
double rand(double a) //returns a value between 0 and a

In your case rand(1), would return a double value between 0 and 1.

You can see rand(1) by creating an Actor: myActor
Now, in the MyActor panel use the Add Event --> Create Actor
--> Add Action -->Create Script
Use the following script:
myActor.textNumber=rand(1);

When you run the program, you will see something like: 0.445357.
Each time your run the program, the number will change.
I've learned that I still have a lot to learn.

** Makslane == Genious **
Just4Fun
 
Posts: 524
Joined: Tue Jul 01, 2003 5:19 am
Location: USA: Washington State; West Coast
Score: 6 Give a positive score

Postby yep » Sat Mar 26, 2005 5:41 am

ty man! for both topicos...
sup?
yep
 
Posts: 15
Joined: Thu Mar 24, 2005 6:28 pm
Score: 0 Give a positive score

Postby willg101 » Sat Mar 26, 2005 2:15 pm

Thanks!
This just what I was about to ask!
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest