Add GetRandomFloat

This commit is contained in:
Jacek 2022-09-03 09:29:52 +02:00 committed by GitHub
parent 462be00230
commit 8b012766d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2812,6 +2812,19 @@ int GetRandomValue(int min, int max)
return (rand()%(abs(max - min) + 1) + min); 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 // Set the seed for the random number generator
void SetRandomSeed(unsigned int seed) void SetRandomSeed(unsigned int seed)
{ {