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.

Newcomers DBPro Corner / Random positioning not really random

Author
Message
TheMan
16
Years of Service
User Offline
Joined: 5th Jul 2008
Location: Florida
Posted: 14th Aug 2008 19:17
Hello,
I'm making a game were the player uses a sphere to move around a 3d enviroment and find a cone, once the sphere collides with the cone, it will move to a random position, heres the code i made for that:
Positioning the object
Make object cone 2, 200
Position object 2, rnd(2000), 0, rnd(2000)
Collision
[center] If object collision (1,2)>0 then position object 2, rnd(2000), 0, rnd(2000)

Pretty simple, but it's not really so random because after a couple of times of playing it, i've noticed that the cone makes itself go to the same "random" positions everytime. Is there any way I can make it go to different positions?
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 14th Aug 2008 19:23
You need to change the rendomizer's seed value. Try putting RANDOMIZE TIMER() at the top of your code. Since Timer() is pretty much an everchanging value, you should almost always have a different randomizing seed value each time (unless the player plays the game, reboots their computer, and plays again at the exact same milisecond as before, which is nearly impossible)

TheMan
16
Years of Service
User Offline
Joined: 5th Jul 2008
Location: Florida
Posted: 14th Aug 2008 19:38
Thanks!
DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 18th Aug 2008 09:56
It would help to put "randomize perftimer()" instead, because when you call rnd() more then once in a row it will sometimes give you the same number if using only "randomize timer()" It won't show up as a command but if you have version 1.066 or up it should compile fine.


I'm Pro grammer.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Aug 2008 20:02
Makes no real difference ... unless you are incorrectly calling randomize over and over again.

DB PROgrammer
17
Years of Service
User Offline
Joined: 9th Feb 2007
Location: Nowhere But Everywhere
Posted: 19th Aug 2008 17:32
Quote: "Makes no real difference ... unless you are incorrectly calling randomize over and over again."


looking back(it was an old project), it seems I was. Oh well, learn somthing new everyday.


I'm Pro grammer.

Login to post a reply

Server time is: 2024-11-25 18:40:35
Your offset time is: 2024-11-25 18:40:35