Thanks god! It almost work!
Hi!
With the help of J Wilton who e-mail me, we almost got the perfect code. There is only one last bug! When the picMan come from the bottom, he pass thrue the picRock but not in the other side! Someone is havint an idea how to fix that? Please help me! :)
:D
here is the code
Dim collision As Boolean, l1&, l2&, r1&, r2&, t1&, t2&, b1&, b2&
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (collision) Then
picMan.Left = picMan.Left - 50
picMan.Top = picMan.Top - 50
picMan.Left = picMan.Left + 50
Exit Sub
End If
If KeyCode = vbKeyUp Then picMan.Top = picMan.Top - 50
If KeyCode = vbKeyDown Then picMan.Top = picMan.Top + 50
If KeyCode = vbKeyLeft Then picMan.Left = picMan.Left - 50
If KeyCode = vbKeyRight Then picMan.Left = picMan.Left + 50
End Sub
Private Sub Timer1_Timer()
l1 = picMan.Left
l2 = picRock.Left
t1 = picMan.Top
t2 = picRock.Top
r1 = picMan.Width + l1
r2 = picRock.Width + l2
b1 = picMan.Height + t1
b2 = picRock.Height + t2
collision = (r1 > l2) And (l1 < r2) And (b1 > t2) And (t1 < b2)
'If (collision) Then imgcool.Visible = True
End Sub