
$ filename "t.exe"
'uses rt32
'uses rtl64
uses window


Window "Follow Me",640,480,2
sys_mode=4

Function Min(single a, b) as single
iF a <= b  
   Return a 
Else 
   Return b
End iF   
End Function

Function Max(single a, b) as single
iF a >= b 
   Return a 
Else 
   Return b
End iF   
End Function

single x, y, rot, vel, tx, ty
single dx, dy, angle, dist, da

While AscKey=0 and WinExit=0
ClsColor 0xcf,0x8c,0xc8
tx = xMouse
ty = yMouse
dx = tx-x
dy = ty-y
dist = Sqr(dx*dx+dy*dy)
angle = ATan (ty-y, tx-x)
da = angle-rot
da = ATan(Sin(da),Cos(da))
vel = Min (1, dist/100.0)
Rot=rot + da *vel   *.1
x=x + Cos(rot) *vel *5
y=y + Sin(rot) *vel *5
Oval x-5, y-5, 20, 30, 255,0,0        '255,255
Events
FlipBuffer
WaitFPS 60
Wend
WinEnd