Random-Function

BlitzPlus Forums/BlitzPlus Programming/Random-Function

JPD(Posted 2003) [#1]
Could it be, that RAND(0,100) generates at every program-start the same number? I've made an asteroids-clone, the planets positions and angles are always the same?!?!

Is that a bug in BlitzPlus? Is there another way to generate Random-Values???

:) J.-P.


Koriolis(Posted 2003) [#2]
See SeedRnd in the docs.
Basically, do SeedRnd(Millisecs()) at the start of the game.


JPD(Posted 2003) [#3]
Thx, it works great now. :) ...


WolRon(Posted 2003) [#4]
Actually, an interesting thing you can do is turn off the SeedRnd code (by commenting it out) for testing purposes.

This will generate the same random numbers every time the game is played. In this way, you can predict (by playing the game a few times) what will happen next, and do something accordingly to find out if a specific section of your code is working correctly.

And it's so easy to turn randomness back on.