cpp-console-game/random-utils/RandomUtils.cpp
2024-07-04 16:57:11 -04:00

26 lines
302 B
C++

#include "RandomUtils.hpp"
#include <time.h>
namespace RandomUtils
{
bool seeded = false;
void seed()
{
if (seeded)
{
return;
}
srand(time(NULL));
seeded = true;
}
int rand(int min, int max)
{
seed();
return min + std::rand() % (max - min + 1);
}
}