ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::random Namespace Reference

Namespaces

namespace  anonymous_namespace{random.cpp}
 

Functions

int random (int max)
 Generate a random integer between 0 and max.
 
int between (int min, int max)
 Generate a random integer between min and max.
 
float random (float max)
 Generate a random float between 0 and max.
 
float between (float min, float max)
 Generate a random float between min and max.
 
bool chance ()
 Generate a random boolean.
 
bool chance (float chance)
 Generate a random boolean with a given chance of being true.
 

Function Documentation

◆ between() [1/2]

float asw::random::between ( float min,
float max )

Generate a random float between min and max.

Parameters
minThe minimum value.
maxThe maximum value.
Returns
float The random number.

Definition at line 27 of file random.cpp.

◆ between() [2/2]

int asw::random::between ( int min,
int max )

Generate a random integer between min and max.

Parameters
minThe minimum value.
maxThe maximum value.
Returns
int The random number.

Definition at line 17 of file random.cpp.

◆ chance() [1/2]

bool asw::random::chance ( )

Generate a random boolean.

Returns
true - Random true.
false - Random false.

Definition at line 32 of file random.cpp.

◆ chance() [2/2]

bool asw::random::chance ( float chance)

Generate a random boolean with a given chance of being true.

Parameters
chanceThe chance of being true between 0 and 1.
Returns
true - Random true.
false - Random false.

Definition at line 37 of file random.cpp.

◆ random() [1/2]

float asw::random::random ( float max)

Generate a random float between 0 and max.

Parameters
maxThe maximum value.
Returns
float The random number.

Definition at line 22 of file random.cpp.

◆ random() [2/2]

int asw::random::random ( int max)

Generate a random integer between 0 and max.

Parameters
maxThe maximum value.
Returns
int The random number.

Definition at line 12 of file random.cpp.