Moved code and assets for the game to a seperate folder. Moved jansson and raylib to third_party.
This commit is contained in:
25
src/game/shared/random.c
Normal file
25
src/game/shared/random.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "random.h"
|
||||
|
||||
void random_init(Random_Generator *random_generator, uint32_t seed) {
|
||||
if(seed == 0) {
|
||||
seed = 1;
|
||||
}
|
||||
random_generator->seed = seed;
|
||||
random_generator->state = random_generator->seed;
|
||||
}
|
||||
|
||||
uint32_t random_u32(Random_Generator *random_generator) {
|
||||
uint32_t x = random_generator->state;
|
||||
|
||||
x ^= x << 13;
|
||||
x ^= x >> 17;
|
||||
x ^= x << 5;
|
||||
|
||||
random_generator->state = x;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
uint32_t random_u32_range(Random_Generator *random_generator, uint32_t min, uint32_t max) {
|
||||
return min + (random_u32(random_generator) % (max - min + 1));
|
||||
}
|
||||
Reference in New Issue
Block a user