move player with keyboard vb.net
Public Class Form1
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
'move player right when right key is pressed
Case Keys.Right
tmrRight.Start()
'move player left when left key is pressed
Case Keys.Left
tmrLeft.Start()
End Select
End Sub
Private Sub tmrRight_Tick(sender As Object, e As EventArgs) Handles tmrRight.Tick
picPlayer.Left += 10
End Sub
Private Sub tmrLeft_Tick(sender As Object, e As EventArgs) Handles tmrLeft.Tick
picPlayer.Left -= 10
End Sub
'stop movement when keys are not pressed
Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles MyBase.KeyUp
tmrLeft.Stop()
tmrRight.Stop()
End Sub
End Class