HGE:Tutorials:Random Numbers

HGE:Tutorials:Random Numbers 

Random numbers in HGE

HGE includes some random number functions. They are member functions of the HGE class. Access them from the global hge pointer declared at the beginning of the program.

Random_Float(float x, float y): Returns a random float between x and y (inclusive).

Random_Int(int x, int y): Returns a random integer between x and y (inclusive).

Random_Seed(int seed=0): Sets the seed for the random number generator. If the seed is zero or omitted, the current time is used for the seed.


Usually, these statements are used in the following way, assuming hge is the global pointer to the HGE interface:

hge->Random_Seed(0);  //sets the seed to the current time
 
int randomNum = hge->Random_Int(30, 50);  //generates a random number from 30 to 50


你可能感兴趣的:(Integer,Random,float,interface,tutorials,Numbers)