diff --git a/demos/random.h b/demos/random.h new file mode 100644 index 0000000..c030012 --- /dev/null +++ b/demos/random.h @@ -0,0 +1,21 @@ +/* This code is by Shaun Marquardt and licenced by GPLv2 + * + * to use these random number stuff, you MUST include the following in your prog: + +#include //These can either be uncommeted OR placed in your C file - Shaun +#include + +* Of course, remember to include this file! */ + +int rnd(int range); +void seedrnd(void); + +int rnd(int range) +{ + return(rand()%range); //spit up random num 0-range +} + +void seedrnd(void) //Seed the randomizer +{ + srand((unsigned)time(NULL)); +}