From a2913485f2b072f0f3c531b9ef2e89ed066ec128 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 5 Nov 2018 07:21:05 -0800 Subject: Fix RNG not changing --- Source/Random.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Source/Random.cpp (limited to 'Source/Random.cpp') diff --git a/Source/Random.cpp b/Source/Random.cpp new file mode 100644 index 0000000..cc3eb6c --- /dev/null +++ b/Source/Random.cpp @@ -0,0 +1,15 @@ +#include + +#include "Random.h" + +int Random::s_seed = time(nullptr); // Seed from the time in milliseconds + +void Random::SetSeed(int seed) { + s_seed = seed; +} + +int Random::RandInt(int min, int max) { + s_seed = (214013 * s_seed + 2531011) % 2147483648; + if (min == max) return min; + return (s_seed % (max - (min - 1))) + min; +} -- cgit 1.4.1