浏览代码

[rcore] Added GetRandomFloat

pull/4653/head
__hexmaster111 2 周前
committed by GitHub
父节点
当前提交
389c9f9de5
找不到此签名对应的密钥 GPG 密钥 ID: B5690EEEBB952194
共有 2 个文件被更改,包括 15 次插入0 次删除
  1. +1
    -0
      src/raylib.h
  2. +14
    -0
      src/rcore.c

+ 1
- 0
src/raylib.h 查看文件

@ -1092,6 +1092,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 random 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

+ 14
- 0
src/rcore.c 查看文件

@ -1781,6 +1781,20 @@ void SetRandomSeed(unsigned int seed)
#endif
}
// Get a random value between min and max included
float GetRandomFloat(float min, float max)
{
if (min > max)
{
float tmp = max;
max = min;
min = tmp;
}
int r = GetRandomValue(0, RAND_MAX);
return r * (max - min) / RAND_MAX + min;
}
// Get a random value between min and max included
int GetRandomValue(int min, int max)
{

正在加载...
取消
保存