Why does this code give odd result?

Blitz3D Forums/Blitz3D Beginners Area/Why does this code give odd result?

Hi there.

Yet another new crazy post today. I've got this bit of code, and I expected the pixels to draw in a random direction outward from the center of the screen. But instead the pixels always gravitate towards the bottom left corner of the screen.

Graphics 1024,768,32,0
SetBuffer BackBuffer()

SeedRnd MilliSecs()

x = 1024/2
y = 768/2

;**********
While Not KeyHit(1)

count# = MilliSecs()

Repeat

direction = Rnd(1,4)

Select True

Case direction = 1
x=x+1: If x >1024 Then x = 1024

Case direction = 2
x=x-1: If x < 0 Then x = 0

Case direction = 3
y=y+1: If y > 768 Then y = 768

Case direction = 4
y=y-1: If y < 0 Then y = 0

Default 

End Select 

Color Rnd(0,255),Rnd(0,255),Rnd(0,255)
Plot x,y

Until MilliSecs()-count# >= 1000/60 

CopyRect 0,0,1024,768,0,0,BackBuffer(),FrontBuffer() 

Wend
;**********


Can someone tell me what very obvious thing I'm missing that causes this code to always trend in the same direction, regardless of the random seed?

Thanks in advance.

direction = Rand(1,4)


instead of:

direction = Rnd(1,4)


Ok cool thanks!

I've read the manual descriptions of Rnd and Rand but I'm not quite sure I get the difference.

Rand (1,4) includes 1,2,3 and 4 whereas Rnd (1,4) only includes 2 and 3?

Rand(1,4) returns integers,
Rnd(1,4) returns floats.


EDIT:
Rand(1,4) returns either 1,2,3 or 4
Rnd(1,4) returns a float between 1.0 and 4.0

Ahh thanks that makes sense now.