Guest KM Posted May 23, 2004 Report Share Posted May 23, 2004 Hi, I'm using that code to start the random function: unsigned int dt = 0; while ((GetAsyncKeyState (VK_RETURN) < 0)==false) { dt = dt++; } srand(dt); but it does not work, and he produce allways the same numbers. Any idea?? Link to comment Share on other sites More sharing options...
Guest Stomski Posted May 24, 2004 Report Share Posted May 24, 2004 srand sets a starting point for the random number generator. To ensure this is different every time you run your app, I would use the time. eg... srand(time(void)); Then to get a random number between say, 0 and 9 inclusive, do: int num = rand() % 10; Link to comment Share on other sites More sharing options...
Guest KM Posted May 24, 2004 Report Share Posted May 24, 2004 I tried this to, but instead of time getsytem... (which return the seconds the system is on). my compiler (evc 2002) doesn't know the time command and the time.h. Any idea?? Link to comment Share on other sites More sharing options...
Guest maxh2003 Posted May 25, 2004 Report Share Posted May 25, 2004 Try srand(GetTickCount()); ... Link to comment Share on other sites More sharing options...
Guest KM Posted May 26, 2004 Report Share Posted May 26, 2004 I have tried this one too, but it is always starts the same map. What is strange that, the pc places the enemies randomly, the map not. I don't know what the bug is. Maybe evc :roll: Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now