![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
A class to generate random numbers. More...
#include <C_random.hpp>
Public Member Functions | |
Random (uint64_t seed) | |
Initialize the random number generator. | |
void | setSeed (uint64_t seed) |
Set the 64-bit seed of the random number generator. | |
template<typename T > | |
T | range (T min, T max) |
Generate a random number within a range. | |
TEngine const & | getEngine () const |
Get the random engine. | |
TEngine & | getEngine () |
Get the random engine. | |
template<typename T > | |
fge::Vector2< T > | rangeVec2 (T min_x, T max_x, T min_y, T max_y) |
Generate a random vector2 within a range. | |
template<typename T > | |
fge::Vector3< T > | rangeVec3 (T min_x, T max_x, T min_y, T max_y, T min_z, T max_z) |
Generate a random vector3 within a range. | |
fge::Color | rangeColor (uint32_t min, uint32_t max) |
Generate a random color. | |
fge::Color | rangeColor (uint8_t min_r, uint8_t max_r, uint8_t min_g, uint8_t max_g, uint8_t min_b, uint8_t max_b, uint8_t min_a, uint8_t max_a) |
Generate a random color. | |
template<typename T > | |
T | rand () |
Generate a random value. | |
template<typename T > | |
fge::Vector2< T > | randVec2 () |
Generate a random vector2. | |
template<typename T > | |
fge::Vector3< T > | randVec3 () |
Generate a random vector3. | |
fge::Color | randColor () |
Generate a random color. | |
std::string | randStr (std::size_t length, std::string const &bucket="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy0123456789") |
Generate a random character sequence. | |
A class to generate random numbers.
This class is a wrapper for the C++ random number generator. It is thread-safe and can be used in a multi-threaded environment.
|
explicit |
Initialize the random number generator.
seed | a 64-bit seed for the random number generator |
|
nodiscard |
Get the random engine.
|
nodiscard |
Get the random engine.
Generate a random value.
T | Type of the random number |
fge::Color fge::Random< TEngine >::randColor | ( | ) |
Generate a random color.
std::string fge::Random< TEngine >::randStr | ( | std::size_t | length, |
std::string const & | bucket = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy0123456789" ) |
Generate a random character sequence.
Generate a random character sequence of the given length and using the given bucket of characters.
length | The length of the character sequence |
bucket | The bucket of characters to use |
fge::Vector2< T > fge::Random< TEngine >::randVec2 | ( | ) |
Generate a random vector2.
T | Type of the random number in the vector |
fge::Vector3< T > fge::Random< TEngine >::randVec3 | ( | ) |
Generate a random vector3.
T | Type of the random number in the vector |
Generate a random number within a range.
T | Type of the random number |
min | Minimum value of the range |
max | Maximum value of the range (included) |
fge::Color fge::Random< TEngine >::rangeColor | ( | uint32_t | min, |
uint32_t | max ) |
Generate a random color.
min | Minimum 32-bit value of the range |
max | Maximum 32-bit value of the range (included) |
fge::Color fge::Random< TEngine >::rangeColor | ( | uint8_t | min_r, |
uint8_t | max_r, | ||
uint8_t | min_g, | ||
uint8_t | max_g, | ||
uint8_t | min_b, | ||
uint8_t | max_b, | ||
uint8_t | min_a, | ||
uint8_t | max_a ) |
Generate a random color.
min_r | Minimum red value of the range |
max_r | Maximum red value of the range (included) |
min_g | Minimum green value of the range |
max_g | Maximum green value of the range (included) |
min_b | Minimum blue value of the range |
max_b | Maximum blue value of the range (included) |
min_a | Minimum alpha value of the range |
max_a | Maximum alpha value of the range (included) |
fge::Vector2< T > fge::Random< TEngine >::rangeVec2 | ( | T | min_x, |
T | max_x, | ||
T | min_y, | ||
T | max_y ) |
Generate a random vector2 within a range.
T | Type of the random number in the vector |
min_x | Minimum value of the x range |
max_x | Maximum value of the x range (included) |
min_y | Minimum value of the y range |
max_y | Maximum value of the y range (included) |
fge::Vector3< T > fge::Random< TEngine >::rangeVec3 | ( | T | min_x, |
T | max_x, | ||
T | min_y, | ||
T | max_y, | ||
T | min_z, | ||
T | max_z ) |
Generate a random vector3 within a range.
T | Type of the random number in the vector |
min_x | Minimum value of the x range |
max_x | Maximum value of the x range (included) |
min_y | Minimum value of the y range |
max_y | Maximum value of the y range (included) |
min_z | Minimum value of the z range |
max_z | Maximum value of the z range (included) |
void fge::Random< TEngine >::setSeed | ( | uint64_t | seed | ) |
Set the 64-bit seed of the random number generator.
seed | a 64-bit seed for the random number generator |