VgaGames 3 - Network man-pages

[.. upper level ..]

VG3_nw_get_random()

Return random integer number suitable for network games.
SYNTAX
unsigned int VG3_nw_get_random(unsigned int value_from, unsigned int value_to)

FUNCTION PARAMETERS
value_from Lowest number to return
value_to Highest number to return

RETURN VALUE
Returns random integer number between including value_from and value_to.

DESCRIPTION
As for network games only key-strokes are sent and received, all computing has to be done by each client for all objects. To keep them in sync, random numbers must not be really random, but replicable by each client. This function returns such replicable numbers and must be used since at least after calling VG3_nw_connect(). It may be used also in non-networking games. Note: This function uses a global seed-number for the whole game. So it could lead to inconsistencies if not all clients would always call it in the right order. To minimize this risk, the function VG3_nw_random_getnext() can instead be used to create pseudo-random numbers suitable for individual code-blocks, e.g. objects.

SEE ALSO
VG3_nw_random_initseed() VG3_nw_random_getnext()