Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,086 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,774 people online right now. Registration is fast and FREE... Join Now!




Multiple KeyPresses at once

 
Reply to this topicStart new topic

Multiple KeyPresses at once

ssenior
20 Jun, 2008 - 05:23 PM
Post #1

New D.I.C Head
*

Joined: 28 May, 2008
Posts: 2


My Contributions
Hi people,

I am currently creating a Space Invaders game. Basically what i want to do is being able to move and shoot at the same time. Simple huh? The problem is that whenever one button is pressed to execute an action it cancels out any other button being pressed. I don't want that to happen. Currently i am just using Key down. Does anyone know how i can have multiple key presses at once?

Private Sub frmain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

Dim Loc As Point

Select Case e.KeyCode
Case Keys.Left
If Not pbplayer1.Location.X - 10 < 0 Then
Loc = New Point(pbplayer1.Location.X - 10, pbplayer1.Location.Y) 'checks where player is on form and if they are inside the form move player
pbplayer1.Location = Loc 'sets a new location of player
End If

Case Keys.Right
If Not pbplayer1.Location.X + 10 > Me.Width - pbplayer1.Width - 10 Then
Loc = New Point(pbplayer1.Location.X + 10, pbplayer1.Location.Y)
pbplayer1.Location = Loc
End If

Case Keys.Space

Call missiletick()

Case Keys.P
'pause game
If gametick.Enabled Then gametick.Stop() _
Else gametick.Start()
If tmrmove.Enabled Then tmrmove.Stop() _
Else tmrmove.Start()

End Select
End Sub

That's my code. This is basically the last thing i need done in my project so any help would be much appreciated.

ssenior
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 11:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month