Fly-like movement?

BlitzMax Forums/BlitzMax Beginners Area/Fly-like movement?

If I had a dot on the screen, how would I make it turn in random directions at random times, like a fly? (only slower)

here we go

Strict

Graphics 800,600,32


Global px:Int = 300
Global py:Int = 300
Global angle:Float = 45
Global counter:Int = 1000
Global lastTickCount:Int
Global currentTickCount:Int


SeedRnd MilliSecs()

While not KeyDown(KEY_ESCAPE)

	currentTickCount = MilliSecs()
	If (currentTickCount- lastTickCount) > counter
		lastTickCount= MilliSecs()		
		counter = Rand(20,200)
		angle = Rnd(360)
	End If

	px :+ Sin(angle)*3
	py :+ Cos(angle)*3
	If px < 0 Then px = 0
	If px > 800 Then px = 800
	If py < 0 Then py = 0
	If py > 600 Then py = 600
	
	Plot px,py
	
	Flip
	Cls
Wend




Ah cool, thanks.