Hi!
I'm a begginer in graphics and games developing...so I want to try to make a liitle game for practice.But I have a question:
Tell me the best way to make some action when the player is pressing some key???
Thanks!
Printable View
Hi!
I'm a begginer in graphics and games developing...so I want to try to make a liitle game for practice.But I have a question:
Tell me the best way to make some action when the player is pressing some key???
Thanks!
Make a picture box and play with the left/top property of the picture box in the keydown event.....thats a good start....
or keypress...
I think it was The Hobo who gave me this code a year ago.
But if there are two players...than how i can get simultanious keypressing???
I hope The Hobo dsn't mind me ****ing up his code....
I have made his example for 2players...
Player 1 moves with the arrows....
PLayer 2 moves with A, S, D, W...
See if you can get it.....
The Homo!?! :eek:
Quote:
Originally posted by Alien_poo
The Homo!?! :eek:
SORRY...I fixed that one up really fast...hehehehe
lol, but the hobo's code did have simultanious keypressing...
that's why I asked for it, for my picture to go diagonaly...
Yes it has...it was a nice demo for starting making games...and I fixed the code so there is two smiles taht can be moved my two diffrent persons...;)Quote:
Originally posted by Alien_poo
lol, but the hobo's code did have simultanious keypressing...
that's why I asked for it, for my picture to go diagonaly...
VB Code:
Dim Keys(0 to 255) as boolean '---------------------- Private Sub Form_Keydown(Keycode,Shift, etc) Keys(Keycode) = true End Sub '---------------------- Private Sub Form_KeyUp(Keycode,Shift,etc) Keys(Keycode) = false End sub
Just check if Keys(#) is true or false to know if a key is pressed, all you have to know is what code each key has.. yes print keycode in keydown to find that out really easily
well.........how would you then make 2 characters move using Direct Draw, you can use the page flip method to make the charater look like he is walking, but how would you make that piece of animation move left and right across the screen. (in a 2d environment). (there are no picture boxes!!!!!!) ??????
No but you have left an top properties of the surfaces (rect)...so just blt your surface at the desired place on the monitor...Quote:
Originally posted by raoul85
well.........how would you then make 2 characters move using Direct Draw, you can use the page flip method to make the charater look like he is walking, but how would you make that piece of animation move left and right across the screen. (in a 2d environment). (there are no picture boxes!!!!!!) ??????
Yes, this is the esiest way, but you will get stuck up if the player (or both of them) are trying to press three or more keys at the same time..;)Quote:
Originally posted by alkatran
VB Code:
Dim Keys(0 to 255) as boolean '---------------------- Private Sub Form_Keydown(Keycode,Shift, etc) Keys(Keycode) = true End Sub '---------------------- Private Sub Form_KeyUp(Keycode,Shift,etc) Keys(Keycode) = false End sub
Just check if Keys(#) is true or false to know if a key is pressed, all you have to know is what code each key has.. yes print keycode in keydown to find that out really easily
I would not recommend using the key events for any game. Poll the keyboard using the API or DirectInput. The VB events are too slow.
The GetASyncKeyState API Works well:D
Yes, it does...I have actually never used it before *embarrassed*, but I think that I will from now on...;)Quote:
Originally posted by RabidChimp
The GetASyncKeyState API Works well:D