Hello,
I am woking on a program which requires the generation of two random numbers to be used as X and Y co-ordinates within a certain range. I have found a random number generator for this:
Code:
int randLim (int min, int max){
int randNo;
srand(time(NULL));
randNo = (rand() % (max - min + 1) + min);
return randNo;
}
And I use it here:
Code:
int randomX = randLim(1,mapX);
//Sometimes put a Sleep(); command in here
int randomY = randLim(1,mapY);
The problem I am having is that most of the time the two numbers are the same, and even if I put in a slight delay to make them different they end up looping through the same numbers over and over (usually going up in 3's or 4's)
I was wondering if anyone had any better ideas to use for a random number generator or if I am going about this wrong.
Many thanks in advance.