Help Needed

Started by
5 comments, last by Takaloy 18 years, 3 months ago
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#?
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.
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.
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.
i know in c++ it will be VK_UP but not sure for c#
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.

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?

This topic is closed to new replies.

Advertisement