Random - Polkm105/DesignPatternPractice GitHub Wiki

COMPLETE

This section contains all functions relating to CP_Random

Table Of Contents

CP_Random_GetBool

Returns a random TRUE or FALSE CP_Bool

Function

CP_Bool CP_Random_GetBool();

Parameters

This function has no parameters

Return

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  CP_Bool bool = CP_Random_GetBool();
}

Related

CP_Random_GetInt

Returns a random unsigned integer

Function

unsigned int CP_Random_GetInt();

Parameters

This function has no parameters

Return

  • unsigned int - a randomly valued int

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  unsigned int random_int = CP_Random_GetInt();
}

Related

CP_Random_RangeInt

Returns a random integer equal to or between the two given values

Function

int CP_Random_RangeInt(int lowerbound, int higherbound);

Parameters

  • lowerbound (unsigned int) - the lowerbound of the random number
  • higherbound (unsigned int) - the higherbound of the random number

Return

  • unsigned int - a randomly valued unsigned int equal to or between the given bounds

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  unsigned int random_int = CP_Random_RangeInt(100, 200);
}

Related

CP_Random_GetFloat

Returns a random float

Function

float CP_Random_GetFloat();

Parameters

This function has no parameters

Return

  • float - a randomly valued float

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  float random_float = CP_Random_GetFloat();
}

Related

CP_Random_RangeFloat

Returns a random float equal to or between the two given values

Function

float CP_Random_RangeFloat(float lowerbound, float higherbound);

Parameters

  • lowerbound (float) - the lowerbound of the random number
  • higherbound (float) - the higherbound of the random number

Return

  • float - a randomly valued float equal to or between the given bounds

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  float random_float = CP_Random_RangeFloat(50.6f, 60);
}

Related

CP_Random_Seed

Set the seed used for generating random numbers

Function

void CP_Random_Seed(int seed);

Parameters

  • seed (int) - the seed that you want to give to the random number generator

Return

This function does not return anything

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  CP_Random_Seed(5);
}

Related

CP_Random_Gaussian

Returns a normally distributed random value where the median is 0 and the standard deviation is 1.

Function

float CP_Random_Gaussian(void);

Parameters

This function does not have any parameters

Return

  • float - the randomly distributed value

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  float random_v = CP_Random_Gaussian();
}

Related

CP_Random_Noise

Returns a smooth random value from 0.0 to 1.0 based on a three dimensional coordinate.

Function

float CP_Random_Noise(float x, float y, float z);

Parameters

  • x (float) - The x coordinate of the value
  • y (float) - The y coordinate of the value
  • z (float) - The z coordinate of the value

Return

  • float - the smoothly distributed value

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  float random_noise = CP_Random_Noise(.3f, .4f, .5f);
}

Related

CP_Random_NoiseSeed

Returns a smooth random value from 0.0 to 1.0 based on a three dimensional coordinate.

Function

void CP_Random_NoiseSeed(int seed);

Parameters

  • seed (int) - The seed to use when distributing noise values

Return

This function does not return anything

Example

void update()
{
  CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
  CP_Random_NoiseSeed(129);
}

Related