Archived

This topic is now archived and is closed to further replies.

key problem

This topic is 5585 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

i''m using this to check for key presses #define keydown(x) (GetAsyncKeyState(x) & 0x8000) i want it so that when you press say space it makes you jump but then you have to let go of space and press it again to jump. how do it do thinf using async type thing. at the moment you can just hold down space and it keep jumping.

Share this post


Link to post
Share on other sites
Simple and fast:

First define a macro checking for key up as well using the Async function, then have a bool called space, init it to true.
Then do something like this:

if(space)
{
// jump code...
space = false;
}
else if(keyup(SPACE_KEYWORD))
{
space = true;
}

Hard work:

Make an array of 256 that keeps track of every key. You will have to make your own keycodes (like ''A'' equals 1 and so on...). But this is pesky if you only need to stop space from going rapid.

Share this post


Link to post
Share on other sites
Also, don''t use GetAsyncKeyState(), use Windows messages. This way you don''t have to poll the keyboard, you just have to check the boolean values.

---
Make it work.
Make it fast.

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites