add GetRandomFloat to public API

This commit is contained in:
Dalton Overmyer 2024-07-12 13:53:37 -05:00
parent 8d5374a443
commit dd295f867f
2 changed files with 9 additions and 0 deletions

View File

@ -1076,6 +1076,7 @@ RLAPI void WaitTime(double seconds); // Wait for so
// Random values generation functions
RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator
RLAPI int GetRandomValue(int min, int max); // Get a random value between min and max (both included)
RLAPI float GetRandomFloat(float min, float max); // Get a float value between min and max (both included)
RLAPI int *LoadRandomSequence(unsigned int count, int min, int max); // Load random values sequence, no values repeated
RLAPI void UnloadRandomSequence(int *sequence); // Unload random values sequence

View File

@ -1761,6 +1761,14 @@ int GetRandomValue(int min, int max)
return value;
}
// Get a random float between min and max included
float GetRandomFloat(float min, float max)
{
float value = min + ((float)GetRandomValue(0, RAND_MAX) / (float)RAND_MAX) * (max - min);
return value;
}
// Load random values sequence, no values repeated, min and max included
int *LoadRandomSequence(unsigned int count, int min, int max)
{