Original Post
Ok, So I have this block of code that I will explain: What happens is if you press ctrl, then two random numbers are gotten between -60, and 60. It keeps setting x to a new random number if that number is within a 10 unit radius of player1. Same for Z. Then my Bad_Guy object (zom) is initialized with the correct coordinates. The problem with this is that it may take a time to find these numbers. What happens is it usually takes 1-2 seconds to get these numbers correct, which slows down my program. Is there a better way to do this that will take much less time? BTW, getRandomNumber() works 100% like it should.
if(keys[VK_CONTROL])
{
double x = getRandomNumber(-60,60), z = getRandomNumber(-60,60);
while( x > (player1->getX() - 10) && x < (player1->getX() + 10) )
{
x = getRandomNumber(-60, 60);
}
while( z > (player1->getZ() - 10) && z < (player1->getZ() + 10) )
{
z = getRandomNumber(-60, 60);
}
zom.init( x , 0, z, 100);
}