adding curved movement

BlitzPlus Forums/BlitzPlus Programming/adding curved movement

Heres another method:

; Chaser

Const sw=640,sh=480

Const sz=25 ; size of square/oval

Graphics sw,sh,0,2
SetBuffer BackBuffer()

x#=Rand(20,sw-20) : y#=Rand(20,sh-20)
destx#=x : desty#=y
speed#=0.05

Repeat
	Cls
	Color 100,100,100
	Text 10,10,"Click LMB to position RED square"
	Text 10,40,"Speed = "+speed
	Text 140,40,"<- Change with Cursor keys LEFT /RIGHT"
	
	If MouseHit(1) Then destx=MouseX() : desty=MouseY()
	speed=speed+Float(KeyDown(205)-KeyDown(203))*0.001
		
	x=x+(destx-x)*speed : y=y+(desty-y)*speed
	
	Color 200,20,20 : Rect destx-sz/2,desty-sz/2,sz,sz
	Color 20,230,20 : Oval x-sz/2,y-sz/2,sz,sz
	
	Flip
Until KeyHit(1)

End