-
Notifications
You must be signed in to change notification settings - Fork 0
Random
This section contains all Random functions.
- CP_Random_GetBool
- CP_Random_GetInt
- CP_Random_RangeInt
- CP_Random_GetFloat
- CP_Random_RangeFloat
- CP_Random_Seed
- CP_Random_Gaussian
- CP_Random_Noise
- CP_Random_NoiseSeed
Returns a random TRUE or FALSE CP_Bool.
CP_Bool CP_Random_GetBool();
This function has no parameters
- CP_Bool - Will be randomly TRUE or FALSE.
void update()
{
CP_Bool bool = CP_Random_GetBool();
}
Returns a random unsigned integer. The returned value will be between 0 and the maximum unsigned int value.
unsigned int CP_Random_GetInt();
This function has no parameters
- unsigned int - The random value.
void update()
{
unsigned int random_int = CP_Random_GetInt();
}
Returns a random integer equal to or between the two given values.
int CP_Random_RangeInt(int lowerbound, int higherbound);
- lowerbound (unsigned int) - The minimum value of the random number.
- higherbound (unsigned int) - The maximum value of the random number.
- unsigned int - A randomly valued unsigned int equal to or between the given bounds.
void update()
{
unsigned int random_int = CP_Random_RangeInt(100, 200);
}
Returns a random float value from 0.0 to 1.0.
float CP_Random_GetFloat();
This function has no parameters
- float - A randomly valued float between 0.0 and 1.0.
void update()
{
float random_float = CP_Random_GetFloat();
}
Returns a random float equal to or between the two given values.
float CP_Random_RangeFloat(float lowerbound, float higherbound);
- lowerbound (float) - The minimum value of the random number.
- higherbound (float) - The maximum value of the random number
- float - A randomly valued float equal to or between the given bounds.
void update()
{
float random_float = CP_Random_RangeFloat(50.6f, 60);
}
Set the seed used for generating random numbers.
void CP_Random_Seed(int seed);
- seed (int) - The seed that you want to give to the random number generator.
This function does not return anything
void update()
{
CP_Random_Seed(5);
}
Returns a normally distributed random value where the median is 0 and the standard deviation is 1.
float CP_Random_Gaussian(void);
This function does not have any parameters
- float - The randomly distributed value.
void update()
{
float random_v = CP_Random_Gaussian();
}
Returns a smooth random value from 0.0 to 1.0 based on a three dimensional coordinate.
float CP_Random_Noise(float x, float y, float z);
- x (float) - The x coordinate of the value.
- y (float) - The y coordinate of the value.
- z (float) - The z coordinate of the value.
- float - The smoothly distributed value.
void update()
{
float random_noise = CP_Random_Noise(.3f, .4f, .5f);
}
Sets a seed value for the values returned by CP_Random_Noise.
void CP_Random_NoiseSeed(int seed);
- seed (int) - The seed to use when distributing noise values.
This function does not return anything.
void update()
{
CP_Random_NoiseSeed(129);
}