frillrun/src/engine/random.c

39 lines
473 B
C
Raw Normal View History

#include "random.h"
void
random_seed_set(u64 seed)
{
jsw_seed(seed);
}
void
random_seed_time_set(void)
{
random_seed_set(jsw_time_seed());
}
f32
random_f32(void)
{
return (f32)jsw_rand() / (f32)UINT_MAX;
}
f32
random_f32_in_range(f32 min, f32 max)
{
2024-08-30 05:18:18 +00:00
return (f32)((random_f32() * (max - min)) + min);
}
s32
random_s32_in_range(s32 min, s32 max)
{
2024-08-30 05:18:18 +00:00
return (s32)((random_f32() * (max - min)) + min);
}
bool
random_bool(void)
{
return random_s32_in_range(0, 2);
}