do `create some coordinates for line a xa1#=rnd(500) ya1#=rnd(500) xa2#=rnd(500) ya2#=rnd(500) `draw line a line xa1#,ya1#,xa2#,ya2# `create some coordinates for line b xb1#=rnd(500) yb1#=rnd(500) xb2#=rnd(500) yb2#=rnd(500) `draw line b line xb1#,yb1#,xb2#,yb2# `find gradient of line a ma#=(ya2#-ya1#)/(xa2#-xa1#) `find gradient of line b mb#=(yb2#-yb1#)/(xb2#-xb1#) `find x coordinate of intersection between lines a and b xi#=(yb1#-mb#*xb1#-ya1#+ma#*xa1#)/(ma#-mb#) `find y coordinate of intersection between lines a and b yi#=ma#*xi#+ya1#-ma#*xa1# `my bit `switch parameters so 1<2 and 3<4 if xa1#>xa2# then i=xa2#:xa2#=xa1#:xa1#=i if xb1#>xb2# then i=xb2#:xb2#=xb1#:xb1#=i if ya1#>ya2# then i=ya2#:ya2#=ya1#:ya1#=i if yb1#>yb2# then i=yb2#:yb2#=yb1#:yb1#=i if (xi#>xa1#) AND (xi#<xa2#) AND (yi#>ya1#) AND (yi#<ya2#) if (xi#>xb1#) AND (xi#<xb2#) AND (yi#>yb1#) AND (yi#<yb2#) `draw circle at point of intersection circle xi#,yi#,10 text 0,15,"Intersect found!" endif endif `end my bit text 0,0,"Press space" wait key cls loop