Edit: I should have had a question mark in the headline, since this is a question. Sorry!
I want to give a flock of sprite birds some randomness to their movement, so they don't end up at the same spot. But I want each birds randomness to be predictable, so that I can set rndSeed = LevelNumber and then the randomness will behave the same way each time the player restarts the level.
I think the function here does most of the stuff the way it's supposed to, but I cant figure out how to randomize the seed. Does anyone here have experience with this?
Global seed# as float = 23.23451
function pseudoRandom (a as integer, b as integer)
// Trying to randomize, but doesn't work
seedText$ as string
seedText$ = str(3.141592653589793 * seed#) REM multiply by pi
seedText$ = Right( seedText$,10)
seedText$ = ReplaceString( seedText$, "7", "." , 1 ) REM replace the first "7" with "."
seed# = ValFloat( seedText$) REM the seed is now a float number
local x# as float REM a value
x# = FMod( seed#, 1.0 ) // x# = something-something to convert seed# to a 0.0 to 1.0 value
// just for testhing with a true random:
// x# = 0.0001 * random(0,10000)
if a > b REM if a is higher, switch a and b
aTmp as integer
aTmp = a
a = b
b = aTmp
endif
c as integer
c = (a*-1) REM if a=7 then c=-7 if a=-4 then c=4 adding this value even the value down to a positive value
b = b + c // 3 === 7
output as integer
output = round(x#*(b+1))
output = output - c
endfunction output