frillrun/src/engine/random.c

40 lines
465 B
C
Raw Normal View History

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