mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-27 05:28:30 +00:00
Add SetRandomSeed(unsigned int seed) function (#1994)
Specifying a fixed seed for the random number generator is often used in games for various reasons. By adding an api function for seeding the random number generator we solve two different problems regarding the seeding: 1) The underlying RNG implementation does not leak to client code (as would be the case if we called srand directly from the client code) 2) Seeding the RNG would be simple from other programming languages (especially in cases where calling libc functions is non-trivial)
This commit is contained in:
@@ -2669,6 +2669,12 @@ int GetRandomValue(int min, int max)
|
||||
return (rand()%(abs(max - min) + 1) + min);
|
||||
}
|
||||
|
||||
// Set the seed for the random number generator
|
||||
void SetRandomSeed(unsigned int seed)
|
||||
{
|
||||
srand(seed);
|
||||
}
|
||||
|
||||
// Check if the file exists
|
||||
bool FileExists(const char *fileName)
|
||||
{
|
||||
|
Reference in New Issue
Block a user