deBUGger Posted January 15, 2004 Posted January 15, 2004 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! Quote
*Experts* mutant Posted January 15, 2004 *Experts* Posted January 15, 2004 Using Keys.Left or Keys.Right instead of others should work. How did you attempt to make it work using the arrows? Quote
deBUGger Posted January 16, 2004 Author Posted January 16, 2004 I did exactly like that and the stupid paddle won't move... at least not with the Keys.Left and Keys.Right... That's strange but true... Quote
splice Posted January 16, 2004 Posted January 16, 2004 match on e.KeyValue() instead To figure out what key it's mapped to just do a Console.WriteLine(e.KeyValue()) Quote -=splice=- It's not my fault I'm a Genius!
p_dog_2007 Posted January 16, 2004 Posted January 16, 2004 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 Quote
Leaders Iceplug Posted January 17, 2004 Leaders Posted January 17, 2004 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. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
ThePentiumGuy Posted January 18, 2004 Posted January 18, 2004 i think it's because he has a label or a command button or something on the form and its taking the default focus Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
hog Posted January 18, 2004 Posted January 18, 2004 ThePentiumGuy yep I was cayght out like this for a while, drove me nuts til I realise what was going on:) Quote My website
ThePentiumGuy Posted January 18, 2004 Posted January 18, 2004 oh yah, here's a tip for you, deBUGger take that button, label or whatever, and put it in a groupbox, that way it wont interfere with the form's default focus ;) Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
deBUGger Posted January 20, 2004 Author Posted January 20, 2004 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.