Hello, I'm programming a game at school, and I have enemys spawning randomly according to the rand() function called each time in the gameloop.
The problem is, the rand function returns same numbers frequently. Here's a example of the output:
r: 6015
r: 13708
r: 6015
r: 6015
r: 6015
r: 6015
r: 6015
r: 13708
r: 31495
r: 29414
r: 31944
r: 6015
r: 6015
r: 6015
r: 6015
r: 13708
r: 31495
r: 29414
r: 31944
r: 27474
r: 6422
r: 2510
as you can see the number 6015 is appearing quite frequently.
The code is about this:
I suppose there is more relevant information, but I don't know exactly what is important, and I can't post the whole program, so if you require more information, please let me know.Code:#include <time.h> int main(){ srand(time(0)); while(...){ cout << rand() << endl; ...delay... } }
Thanks!