srand without using time

I'm making a game with 'comets' falling from the top of the screen that you have to dodge and I'm using srand(time(NULL)); to decide the starting x location of each comet. The problem is that the comets spawn often and the spawns follow a pattern of going left to right. I'm pretty sure this is happening because I'm using time. Anyway I was wondering what alternatives there are to using time in srand. Any suggestions would be appreciated.
I think I know what your problem is. You should be calling srand only once in your program.
I removed it completely and tried adding it once in various parts of my code, but there's no difference. I don't think I could use it just once anyway, because I have 2 classes that use random numbers.
As hamsterman said, srand should be called once and only once during the lifetime of the program. You do not call it for every randomly generated number.

In your classes that use random numbers, just have them call rand(). Then put a srand() at the beginning of main. Don't put srand anywhere else in the program.
Try not calling srand at all. The purpose of srand is to make sure that when you start the program you don't get the exactly same numbers as last time. It does not affect the randomness itself.
srand needs to be called once (not in a loop, before calling rand. a good place could be the first line of main() )
Thanks guys, I got it to work properly now.
Topic archived. No new replies allowed.