Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / w,a,s,d?

Author
Message
mike5424
15
Years of Service
User Offline
Joined: 30th Mar 2009
Location:
Posted: 27th May 2009 20:44
how do i use the w,a,s and d keys? would it be keystates?

www.madninjas.co.nr we are mad and we are ninjas
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 27th May 2009 21:45 Edited at: 28th May 2009 03:59
Yep you can use dbKeyState() to get if any key on the keyboard is pressed or not. You can manually go get the scan codes, but that takes a while and some memorization.

The better and easier way of getting key scan codes is to include "dinput.h" in your program.
This will allow you to use predefined numbers like this:


Instead of:


It's a lot easier to read and understand. Keys like the space bar would be something like DIK_SPACE and the right shift would be DIK_RSHIFT etc. Look into the header file toward the end for all of the definitions.

#ifdef _DEBUG
FixBugs(All);
#endif
endre3000
15
Years of Service
User Offline
Joined: 20th May 2009
Location:
Posted: 27th May 2009 22:16
Good one! I had been making my own scancode constants until now... how are users expected to find out this stuff?
endre3000
15
Years of Service
User Offline
Joined: 20th May 2009
Location:
Posted: 27th May 2009 22:24
Oh, I just realised dinput.h is a DirectX thing not a GDK/TGC thing... Feels good to know I'm not just playing with a proprietary system, if DGDK is a way to ease me into learning DX all the better.
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 27th May 2009 22:34
or you could just use #define, right?
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 27th May 2009 22:49
They are defined in the header file. Why define something that is already defined for you?

#ifdef _DEBUG
FixBugs(All);
#endif
mike5424
15
Years of Service
User Offline
Joined: 30th Mar 2009
Location:
Posted: 28th May 2009 10:48
thanks.

www.madninjas.co.nr we are mad and we are ninjas

Login to post a reply

Server time is: 2024-11-05 23:17:05
Your offset time is: 2024-11-05 23:17:05