Rand_GetBetween

This commit is contained in:
2021-04-26 23:54:56 +02:00
committed by Valeriano A.R
parent 80a15daa86
commit 7482cb6868
2 changed files with 11 additions and 0 deletions

View File

@@ -341,6 +341,13 @@ unsigned Rand_Get() {
return (val);
}
unsigned Rand_GetBetween(int min, int max) {
if (min == max) {
return max;
}
return (Rand_Get() % (max - min)) + min;
}
/////////////////////////////
// Print
//

View File

@@ -87,9 +87,13 @@ int EndsWith(char *str, char *suffix);
// Rand
//
void Rand_Seed(unsigned seed);
unsigned Rand_Get();
#define Rand_GetFloat(x) (((float)(Rand_Get() % 1048576)) / 1048576.0f)
unsigned Rand_GetBetween(int min, int max);
/////////////////////////////
// Print
//