Bryce Gough
Active member
hello, I have made a multiplayer (2 people on one keyboard) shooting game in vb.net, and I need help with the movment, at the moment everyone can move fine, but if someone shoots or moves while someone else is moving, then only one person can move at a time.
How would I change the code so more than one keypress can be picked up at once, I would like the code to be short, but any code will do and help me!
Here is my code:
Please help me
How would I change the code so more than one keypress can be picked up at once, I would like the code to be short, but any code will do and help me!
Here is my code:
VB.NET:
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If PauseMenu.Visible = True Then
If e.KeyValue = Keys.Escape Then
PauseMenu.Hide()
gameenabled = True
End If
Else
If e.KeyValue = Keys.Escape Then
PauseMenu.Show()
gameenabled = False
End If
End If
If gameenabled = True Then
'Player1 Controls
If e.KeyValue = Keys.A Then
player.Image = My.Resources.stand
My.Settings.Position = False
player.Location = New Point(player.Location.X - 10, player.Location.Y - 0.5)
ElseIf e.KeyValue = Keys.D Then
player.Image = My.Resources.standow
My.Settings.Position = True
player.Location = New Point(player.Location.X + 10, player.Location.Y + 0.5)
End If
If e.KeyValue = Keys.Space Then
JumpUp.Enabled = True
End If
If e.KeyValue = Keys.ShiftKey Then
shoot()
End If
'End Player1 Controls
'Player2 Contols
If e.KeyValue = Keys.Left Then
player2.Image = My.Resources.player2stand
My.Settings.P2Position = False
player2.Location = New Point(player2.Location.X - 10, player2.Location.Y - 0.5)
ElseIf e.KeyValue = Keys.Right Then
player2.Image = My.Resources.player2standow
My.Settings.P2Position = True
player2.Location = New Point(player2.Location.X + 10, player2.Location.Y + 0.5)
End If
If e.KeyValue = Keys.Up Then
p2JumpUp.Enabled = True
End If
If e.KeyValue = Keys.Down Then
player2shoot()
End If
'End Player2 Controls
Else
End If
End Sub
Please help me