From 0928b5cbbde02d4a6c58ca940040ae4a1c2ac2e4 Mon Sep 17 00:00:00 2001 From: citrons Date: Sat, 14 Oct 2023 00:20:50 -0500 Subject: give the terrain a texture --- random.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'random.c') diff --git a/random.c b/random.c index c53d378..90dc3b5 100644 --- a/random.c +++ b/random.c @@ -2,14 +2,25 @@ static Uint64 random = 0xbee; +Uint64 hash(Uint64 n) { + Uint64 h = 0; + for (int i = 0; i < 8; i++) { + h += (n >> i * 8) & 0xFF; + h += h << 10; + h ^= h >> 6; + } + h += h << 3; + h ^= h >> 11; + h += h << 15; + return h; +} + void seed_rand(Uint64 seed) { random ^= seed; } Uint64 get_rand() { - random ^= random >> 7; - random ^= random << 9; - random ^= random >> 13; + random = hash(random); return random; } -- cgit v1.2.3