Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Program Help

Author
Message
izic
15
Years of Service
User Offline
Joined: 9th Sep 2009
Location:
Posted: 14th Apr 2010 00:05
Good afternoon fellow coders. I'm working on a program that draws a square at a random location. Everything works fine and the square is drawn, but the only problem is that it isn't drawn at a random location. Can anyone help?

Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 14th Apr 2010 17:59
If you use the dbRandomize() command at the begining of your program it will generate a different set of random numbers.

dbRND() is random but the random values will allways return the same. So if you use dbRandomize() with a value thats different you will allways get a completly random, random number with dbRND().

Alot of people use the System Timer to give the dbRandomize() a differnt seed value. so dbRandomize(dbTimer()); ,Though you could allways store a value in an external text file and each time your program runs increase the value and seed dbRandomize with that.


From the Documentation:

dbRandomize
The dbRandomize command reseeds the random number generator. If the random number generator is not reseeded the dbRND command can return the same sequence of random numbers. To change the sequence of random number every time the program is run, place a dbRandomize statement with an integer number at the beginning of the program and change the value with each run.

Syntax
void dbRandomize ( int iSeed )

Login to post a reply

Server time is: 2024-10-02 03:33:19
Your offset time is: 2024-10-02 03:33:19