Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
random.h File Reference

Provides random number generation functionality for integers, floats, and boolean values. More...

#include <stdlib.h>
#include <time.h>
#include <stdbool.h>

Go to the source code of this file.

Functions

void RandomInit ()
 Initializes the random number generator.
 
int RandInt (int min, int max)
 Generates a random integer between min and max (inclusive).
 
float RandFloat (float min, float max)
 Generates a random float between min and max.
 
bool RandBool ()
 Generates a random boolean value.
 

Detailed Description

Provides random number generation functionality for integers, floats, and boolean values.

These functions can be used to generate random integers and floats. To use these functions, call RandomInit() once at the start of the program. Then, call RandInt() or RandFloat() to get random numbers.

Author
Mango
Date
2025-03-03

Function Documentation

◆ RandBool()

bool RandBool ( )

Generates a random boolean value.

Returns
A random boolean value (true or false).

Generates a random boolean value.

Returns either true or false with equal probability (50%).

Returns
bool Either true or false

◆ RandFloat()

float RandFloat ( float  min,
float  max 
)

Generates a random float between min and max.

Parameters
minThe minimum value.
maxThe maximum value.
Returns
A random float between min and max.

Generates a random float between min and max.

Creates a random floating-point value that is >= min and <= max. The distribution is uniform across the range.

Parameters
minThe minimum value (inclusive)
maxThe maximum value (inclusive)
Returns
float A random float between min and max

◆ RandInt()

int RandInt ( int  min,
int  max 
)

Generates a random integer between min and max (inclusive).

Parameters
minThe minimum value.
maxThe maximum value.
Returns
A random integer between min and max.

Generates a random integer between min and max (inclusive).

Creates a random integer value that is >= min and <= max. The distribution is uniform across the range.

Parameters
minThe minimum value (inclusive)
maxThe maximum value (inclusive)
Returns
int A random integer between min and max

◆ RandomInit()

void RandomInit ( )

Initializes the random number generator.

This function should be called once at the start of the program.

Initializes the random number generator.

Seeds the random number generator with a time-based value to ensure different sequences on each program run.