cpp-console-game/random-utils/RandomUtils.cpp

26 lines
302 B
C++
Raw Normal View History

2024-07-04 21:57:11 +01:00
#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);
}
}