Hello,
I'm kinda new to visual basic and i'm working to a game but there is a problem: When i move my person to a tree it stops moving but i cant start moving again.
I just want to stop my person to run through the tree but still able to move other directions.
Here is my code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.Left
If red.Bounds.IntersectsWith(boom.Bounds) Then
Me.red.Left -= 0
Exit Select
Else : Me.red.Left -= 7.8
End If
Case Keys.Up
If red.Bounds.IntersectsWith(boom.Bounds) Then
Me.red.Left += 0
Exit Select
Else : Me.red.Top -= 7.8
End If
Case Keys.Right
If red.Bounds.IntersectsWith(boom.Bounds) Then
Me.red.Left -= 0
Exit Select
Else : Me.red.Left += 7.8
End If
Case Keys.Down
If red.Bounds.IntersectsWith(boom.Bounds) Then
Me.red.Top += 0
Exit Select
Else : Me.red.Top += 7.8
Exit Select
End If
End Select
End Sub
I'm kinda new to visual basic and i'm working to a game but there is a problem: When i move my person to a tree it stops moving but i cant start moving again.
I just want to stop my person to run through the tree but still able to move other directions.
Here is my code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.Left
If red.Bounds.IntersectsWith(boom.Bounds) Then
Me.red.Left -= 0
Exit Select
Else : Me.red.Left -= 7.8
End If
Case Keys.Up
If red.Bounds.IntersectsWith(boom.Bounds) Then
Me.red.Left += 0
Exit Select
Else : Me.red.Top -= 7.8
End If
Case Keys.Right
If red.Bounds.IntersectsWith(boom.Bounds) Then
Me.red.Left -= 0
Exit Select
Else : Me.red.Left += 7.8
End If
Case Keys.Down
If red.Bounds.IntersectsWith(boom.Bounds) Then
Me.red.Top += 0
Exit Select
Else : Me.red.Top += 7.8
Exit Select
End If
End Select
End Sub