Small random function

Previous topic - Next topic

monono

I use this quite extensively:
Code (glbasic) Select

FUNCTION QRND: b, e=0 , scale=1
LOCAL n = ABS(e-b)
RETURN b+ n/(scale*n)*RND(scale*n)
ENDFUNCTION


Examples:
QRND(20) - nothing special, like RND(20)
QRND(20,100) - numbers between 20 and 100
QRND(20,100,10) -numbers between 20 and 100 and 10 steps from one number to the next one  20,20.1...99.9,100
and so on..
Works with negative numbers.

Scott_AW

That is a nice function, I always go about just adding and subtracting after the random, this would be less typing and easier to handle.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

monono