Ok, here's what i conjured up. It might not be what your after though:
It basically start with the mode set to 0. This is a one time only event. Once you have clicked to set a position, it creates a type and inputs the start co-ords. For every other click, it inputs the end co-ord into the type object, and create a new link, type object, with the same end co-ords as the last type. This is done in the "add_link" function.
Graphics 800,600 SetBuffer BackBuffer() Const box_size = 32 Dim boxes(10,10) ; second dimension holds x,y co-ords - 0 = x, 1 = y Global box = CreateImage(box_size,box_size) SetBuffer ImageBuffer(box) Rect 0,0,box_size,box_size Color 50,50,50 Rect 0,0,box_size,box_size,0 SetBuffer BackBuffer() Type link Field from_x,from_y Field to_x, to_y Field complete ; 1 = link is complete. 0 = link is waiting for destination co-ords. End Type Global start_draw_x = 100 Global start_draw_y = 100 Global mode = 0 ; 0 = first pick ; 1 = next pick Global first_click = 1 Global pos_x,pos_y While Not KeyHit(1) If MouseHit(1) Then If mode = 0 Then ; if first click basically If check_click(MouseX(),MouseY()) = True Then set_start_point(pos_x, pos_y) mode = 1 End If ElseIf mode = 1 Then If check_click(MouseX(),MouseY()) = True Then add_link(pos_x, pos_y) End If End If End If draw_boxes() draw_links() Flip Wend Function draw_boxes() For loopx = 0 To 10 For loopy = 0 To 10 DrawImage box, start_draw_x + (loopx*box_size), start_draw_y + (loopy*box_size) Next Next End Function Function draw_links() For l.link = Each link If l\complete = 1 Then Color 100,100,255 ; calculate pixel co-ords. Add box_size * 0.5 so links come from the centre of boxes. start_x = start_draw_x + (l\from_x * box_size) + (box_size*0.5) start_y = start_draw_y + (l\from_y * box_size) + (box_size*0.5) finish_x = start_draw_x + (l\to_x * box_size) + (box_size*0.5) finish_y = start_draw_y + (l\to_y * box_size) + (box_size*0.5) Line start_x,start_y,finish_x,finish_y Else ; draw a marker for the last position Color 0,0,0 start_x = start_draw_x + (l\from_x * box_size) + (box_size*0.5) start_y = start_draw_y + (l\from_y * box_size) + (box_size*0.5) Oval start_x-1, start_y-1, 2,2 End If Next End Function Function check_click(x,y) For loopx = 0 To 10 For loopy = 0 To 10 If RectsOverlap(x,y,1,1, start_draw_x + (loopx*box_size) , start_draw_y + (loopy*box_size), box_size,box_size) Then pos_x = loopx pos_y = loopy Return True End If Next Next End Function Function set_start_point(x,y) l.link = New link l\from_x = x l\from_y = y l\complete = 0 End Function Function add_link(x,y) l.link = Last link l\to_x = x l\to_y = y l\complete = 1 l.link = New link l\from_x = x l\from_y = y l\complete = 0 End Function
It basically start with the mode set to 0. This is a one time only event. Once you have clicked to set a position, it creates a type and inputs the start co-ords. For every other click, it inputs the end co-ord into the type object, and create a new link, type object, with the same end co-ords as the last type. This is done in the "add_link" function.