From 8b012766d815b00007382ce919885a9f8fc3856a Mon Sep 17 00:00:00 2001 From: Jacek Date: Sat, 3 Sep 2022 09:29:52 +0200 Subject: [PATCH] Add GetRandomFloat --- src/rcore.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rcore.c b/src/rcore.c index b0f28ccc3..f738be603 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -2812,6 +2812,19 @@ int GetRandomValue(int min, int max) return (rand()%(abs(max - min) + 1) + min); } +// Get a random float value between min and max (both included) +float GetRandomFloat(float min, float max) +{ + if (min > max) + { + float tmp = max; + max = min; + min = tmp; + } + + return min + ((float)rand() / (float)RAND_MAX) * (max - min); +} + // Set the seed for the random number generator void SetRandomSeed(unsigned int seed) {