shithub: ft²

ref: 60d213d2a215dc1c764507b51a065d81b6a2a8d7
dir: /src/ft2_random.c/

View raw version
#include <SDL2/SDL.h>
#include <stdint.h>
#include <stdbool.h>

static uint32_t randSeed;

void randomize(void)
{
	randSeed = (uint32_t)SDL_GetTicks();
}

int32_t randoml(int32_t limit)
{
	randSeed *= 134775813;
	randSeed++;
	return ((int64_t)randSeed * (int32_t)limit) >> 32;
}

int32_t random32(void)
{
	randSeed *= 134775813;
	randSeed++;

	return randSeed;
}