Jump to content
  • Advertisement
Sign in to follow this  
Takaloy

Help Needed

This topic is 4656 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

call me an idiot, but anyone but what's the keyboard case byte capture for the "up", "down", "left", "right" arrows for C#? my code looks like this and I indend to change the w s a d, to the arrows. Also, can I use switch case, to say move diagonally by pressing 2 movement keys at the same time? Thanks in advance! private static void Keyboard(byte key, int x, int y) { switch(key) { case (byte) 'w': case (byte) 'W': if(heroShip.positionYGet() < (topW-5)) heroShip.moveUp(); break; } } another issue, how do I set a timer function for C#?

Share this post


Link to post
Share on other sites
Advertisement
Can't comment on the other questions, but if you want pressing two keys at once to move you diagonally you'll want a series of 'if' statements rather than a switch statement.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Can't comment on the other questions, but if you want pressing two keys at once to move you diagonally you'll want a series of 'if' statements rather than a switch statement.


Ugh. If you're going for that approach, you also need to be aware of keyboard masking and ghosting issues.

Share this post


Link to post
Share on other sites
can't go with ifs, I think.
I tried with if but it doesn't go diagonally either. but anyway that's not the main issue. I can't seem to find the key that captures the arrow movements.

Share this post


Link to post
Share on other sites
the arrow keys are 2 key presses

(byte)(-32)
then
(byte)'H' for up
(byte)'P' for down
(byte)'K' for left
(byte)'M' for right

^^the capitals are important, '-32''h' is not the up arrow key.

Other keys show up with the '-32' tag.
And F1 - F10 show up with a '0' tag.

'-32''I' is page_up, '-32''Q' is page_down for instance.
it is really easy to make a simple app to getch everything you type and give you the real output of what was just typed.

Share this post


Link to post
Share on other sites
Quote:
Original post by KulSeran
the arrow keys are 2 key presses

(byte)(-32)
then
(byte)'H' for up
(byte)'P' for down
(byte)'K' for left
(byte)'M' for right

^^the capitals are important, '-32''h' is not the up arrow key.

Other keys show up with the '-32' tag.
And F1 - F10 show up with a '0' tag.

'-32''I' is page_up, '-32''Q' is page_down for instance.
it is really easy to make a simple app to getch everything you type and give you the real output of what was just typed.



thanks! does that mean I have do use "if" and "else" instead of switch?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!