Add base game

This commit is contained in:
2024-07-04 16:57:11 -04:00
parent 85e4a03a90
commit 716ae24600
16 changed files with 520 additions and 11 deletions

View File

@ -0,0 +1,11 @@
add_library(
RandomUtils
RandomUtils.hpp
RandomUtils.cpp
)
target_include_directories(
RandomUtils
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

View File

@ -0,0 +1,26 @@
#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);
}
}

View File

@ -0,0 +1,14 @@
#ifndef RANDOM_HPP
#define RANDOM_HPP
#include <cstdlib>
namespace RandomUtils
{
/**
* Generates a random number between min and max (inclusive).
*/
int rand(int min = 0, int max = RAND_MAX);
}
#endif // RANDOM_HPP