I'm trying to trap the 'W' key with the following code, but it doesn't work:
Code:if (KEY_DOWN(VK_W))
// Move player two up
Neither works...Code:if (KEY_DOWN(57))
// Move player two up
Printable View
I'm trying to trap the 'W' key with the following code, but it doesn't work:
Code:if (KEY_DOWN(VK_W))
// Move player two up
Neither works...Code:if (KEY_DOWN(57))
// Move player two up
Try using GetAsyncKeyState instead of KEY_DOWN.
What is KEY_DOWN?? Where did u get that? Is it a MACRO of some sort? Try what abdul said or just do a
#define KEY_DOWN(x) GetAsyncKeyState(x)
I've had troubles with it :(
GetAsyncKeyState will return 0 if it fails so you should check it like this....
Remember the code for the "W" key is in hexadecimal (0x57), not just 57.PHP Code:if(GeAsyncKeyState(0x57) != 0)
{
//Key was pressed
}
oohhh! now I get it! :D thx!
The return value of GetAsyncKeyState should only be tested for the highest bit set:
Code:inline bool KEY_DOWN(int vk) {
return (GetAsyncKeyState(vk) & 0x80) != 0;
}