FS2_Open
Open source remastering of the Freespace 2 engine
floating.cpp File Reference
#include <stdlib.h>
#include "io/timer.h"
#include "math/floating.h"

Go to the source code of this file.

Functions

float fl_roundoff (float x, int multiple)
 Rounds off a floating point number to a multiple of some number. More...
 
float frand ()
 Return random value in range 0.0..1.0- (1.0- means the closest number less than 1.0) More...
 
float frand_range (float min, float max)
 Return a floating point number in the range min..max. More...
 
int rand_chance (float frametime, float chance)
 Call this in the frame interval to get TRUE chance times per second. More...
 

Function Documentation

float fl_roundoff ( float  x,
int  multiple 
)

Rounds off a floating point number to a multiple of some number.

Parameters
xInput floating point number
multipleMultiple to round to

Definition at line 21 of file floating.cpp.

float frand ( )

Return random value in range 0.0..1.0- (1.0- means the closest number less than 1.0)

Definition at line 35 of file floating.cpp.

float frand_range ( float  min,
float  max 
)

Return a floating point number in the range min..max.

Parameters
minMinimum (inclusive)
maxMaxiumum (inclusive)

Definition at line 50 of file floating.cpp.

int rand_chance ( float  frametime,
float  chance 
)

Call this in the frame interval to get TRUE chance times per second.

If you want it to return TRUE 3 times per second, call it in the frame interval like so: rand_chance(flFrametime, 3.0f);

Parameters
frametime
chance

Definition at line 66 of file floating.cpp.