Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi everyone!

 

I'm developing the arcanoid game for a subject at uni, and I can already make te paddle move to the left and right, but somehow I can't manage to do it with the reft and right arrow keys, I have to use other keys...

 

Can anyone tell me how can that be done? the code I'm using is this one:

 

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

If e.KeyCode = Keys.P Then

plataforma.mover(xr, (xr + 5))

xr = xr + 5

ElseIf e.KeyCode = Keys.Q Then

plataforma.mover(xr, (xr - 5))

xr = xr - 5

End If

End Sub

 

 

Thanks in advance!

Posted

match on e.KeyValue() instead

 

To figure out what key it's mapped to just do a Console.WriteLine(e.KeyValue())

-=splice=-

It's not my fault I'm a Genius!

Posted

re:

 

hey i had the same problem, its prably because your using the keypress event for some reason the arrow keys dont work with keypress.

 

solution: Use keydown event not keypress

 

hope that helps

  • Leaders
Posted

Looks like he's using the KeyDown event already. :-\

 

debugger: Try adding

 

Else

MessageBox.Show("At least the event still fires for the keys.")

 

before the End If and see if the MessageBox still shows. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
Yeah, people!!! Thanks for your help! And to ThePentiumGuy, you are very right, it's the button focus that is getting on the way! I tried the code again without the button in the form, and it worked! And I sure will try what you said! thank you all! :cool: :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...