diff --git a/src/raylib.h b/src/raylib.h index 60ec3c23e..ee734c051 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -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 diff --git a/src/rcore.c b/src/rcore.c index e68a9a7d5..ee45f55e8 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -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) {