8 Random::Random() : lastResultInt(0), lastResultFloat(0.0f)
11 srand(
unsigned int(time(
nullptr)));
14 int const& Random::GenerateInt(
int const& min,
int const& max)
19 debug_warning(
"Random",
"GenerateInt",
"Passed Min value is larger than passed Max, returning GenerateInt() with passed Min as Max and passed Max as Min.");
20 return GenerateInt(max, min);
26 debug_warning(
"Random",
"GenerateInt",
"Min and Max values passed have the same value, returning passed Min value.");
31 lastResultInt = rand() % (max + 1 - min) + min;
37 float const& Random::GenerateFloat(
float const& min,
float const& max)
42 debug_warning(
"Random",
"GenerateFloat",
"Passed Min value is larger than passed Max, returning GenerateInt() with passed Min as Max and passed Max as Min.");
43 return GenerateFloat(max, min);
49 debug_warning(
"Random",
"GenerateFloat",
"Min and Max values passed have the same value, returning passed Min value.");
54 const float shifter = 1000.0f;
55 lastResultFloat = float(rand() %
int(floorf((max - min) * shifter))) / shifter + min ;
58 return lastResultFloat;
#define debug_warning(debug_class, function, value)
This functions logs a debug warning to the log and console.