$ filename "t.exe"
'uses rtl32
'uses rtl64


indexbase 0
include "window.inc"

Sub SetFont(sys width, height, flag, string font)  
sys hFont
hFont = CreateFont height,width,0,0,flag,0,0,0,0,0,0,0,0,font
SelectObject bHdc, hFont
SetBkMode bHdc,1
DeleteObject hFont
End Sub

Sub SetText(string txt, sys x, y, color) 
SetTextColor bHdc, color
TextOut bHdc,x,y,txt,Len(txt)
End Sub

Sub Box(int x,y,w,h,c)  
int iBrush
iBrush = CreateSolidBrush c
SelectObject bHdc, iBrush
Rectangle bHdc,x,y,w+x,h+y
DeleteObject iBrush
End Sub

Sub Circle(int x,y,r,c)       
int iBrush
iBrush = CreateSolidBrush c
SelectObject bHdc, iBrush
Ellipse bHdc,x,y,x+r*2,y+r*2
DeleteObject iBrush
End Sub

Sub WaitFrames(sys Frame)    
QueryPerformanceFrequency sys_Freq                                                                                          
sys_Interval = sys_Freq/Frame  
While (1)                                                                       
QueryPerformanceCounter sys_cT2                                                 
iF sys_cT2 >= sys_cT1 + sys_Interval                                             
QueryPerformanceCounter sys_cT1                                              
Exit Sub            
End iF
Wend                                                                             
End Sub


Window "Distance",800,220,2
SetFont 12,24,0,""

sys a1, b1=100, a2=800-64, b2=100, w
sys xWall=368, yWall=100

While WinExit=0
if AscKey=27 then exit while
clsColor 0,0,0
float distance=hypot(a1-xwall,b1-ywall)
Text 0,0,"Distance = " + Str(Distance),0xff,0xff,0xff
circle a2,b2,32,255
Box xwall,ywall,64,64,0x00FFFF
Circle a1,b1,32,0x00FF00
iF Distance=64
Text 346,24,"Press Space",0,200,255
WaitKey 32
End iF
a1 +=2
a2 -=2
iF a1 >=864 
   a1= -a1
   w =1    
End iF
iF a2 <=0 Then a2=xwall+64
iF w=1 Then Text 366,0,"Wait", 255,255,255
Events
FlipBuffer
WaitFrames 120
Wend
WinEnd
