I have to lines on a form....
Line1 is "standing up", line1 is laying down.
I'm moving Line2 towards line1, and want to detect thwn the "tip" of Line2 touches Line1..
I have the following code:
Code:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Sub Timer1_Timer() If GetAsyncKeyState(vbKeyLeft) Then Line2.X1 = Line2.X1 - 80 Line2.X2 = Line2.X2 - 80 End If If GetAsyncKeyState(vbKeyRight) Then Line2.X1 = Line2.X1 + 80 Line2.X2 = Line2.X2 + 80 If Line2.X1 > Line1.X2 Then Me.Caption = "Colission!" End If End If If GetAsyncKeyState(vbKeyUp) Then Line2.Y1 = Line2.Y1 - 80 Line2.Y2 = Line2.Y2 - 80 End If If GetAsyncKeyState(vbKeyDown) Then Line2.Y1 = Line2.Y1 + 80 Line2.Y2 = Line2.Y2 + 80 End If End Sub




Reply With Quote