; RectsOverlap Example ; -------------------- Graphics 640,480,0,2 SetBuffer BackBuffer() ; The player rectangle, steered with the arrow keys px=100 py=100 While Not KeyDown(1) Cls If KeyDown(203) Then px=px-3 If KeyDown(205) Then px=px+3 If KeyDown(200) Then py=py-3 If KeyDown(208) Then py=py+3 ; Pure rectangle maths - no images involved, the fastest overlap test hit=RectsOverlap(px,py,60,40,270,190,100,100) ; The fixed zone - red while the player rectangle overlaps it If hit Then Color 255,60,60 Else Color 80,200,80 End If Rect 270,190,100,100,False ; The player rectangle Color 255,255,255 Rect px,py,60,40,True Text 0,0,"Arrow keys: move your rectangle into the zone Esc: exit" Text 0,20,"RectsOverlap("+px+","+py+",60,40,270,190,100,100)="+hit Flip Wend End