Posted: 15th Jun 2003 14:07
Some times I want to add an extra plus or minus factor, especially when I create objects in space, where their relative position is specified but I want to add an element of randomness.

So here it is, a cute one liner:

+ Code Snippet
`This generates a random Plus or Minus 1 by =C=
function rndpm()
   li_pm = -1 + RND(2)
endFunction li_pm



I hope you enjoy it and that it will get a small place in your code library. and in your hearts!

=C=
Posted: 18th Jun 2003 0:05
or if you just want 1 or -1 without 0 you could try this.
+ Code Snippet
do


li_pm = -1 + RND(3)
if li_pm = 2
li_pm=-1
endif
if li_pm = 0
li_pm=1
endif
print li_pm

loop
Posted: 18th Jun 2003 7:44
or... for only a 1 or -1 in one line of code...

a=(rnd(1)-0.5)*2

...well...thats it...
Posted: 22nd Jun 2003 20:58
Game Creator, this is the newest version I came up with too. I wont even bother posting it. Well done!