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 / Movement with keys

Author
Message
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 14th May 2008 17:55
Right now Im using this code for moveing the player



But I cant detect for W and A at the same time. How can I do this?

Niels Henriksen
www.tales-of-the-realms.com
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 14th May 2008 18:05 Edited at: 14th May 2008 19:04
Try using dbKeyState (int iScanCode) which returns 1 if the particular key is being pressed.

At a quick guess



The thing to keep in mind is that this doesn't imply "just pressed". If they're both pressed the next time the loop cycles, you'll get the same response if the keys are still being held down. You'll need to arrange a mechanism detected the keys being releasesd if you don't want repeated activation in a fast loop.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
tobi453
19
Years of Service
User Offline
Joined: 28th Apr 2005
Location:
Posted: 14th May 2008 18:06
Use:
if(dbKeyState(17)==1){do something...}
if(dbKeyState(31)==1){do something...}
if(dbKeyState(30)==1){do something...}
if(dbKeyState(32)==1){do something...}

FINAL VERSION RELEASED!!!!
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 14th May 2008 20:13
Thanks Lilith and tobi.... its working perfect

Niels Henriksen
www.tales-of-the-realms.com

Login to post a reply

Server time is: 2024-09-29 19:11:37
Your offset time is: 2024-09-29 19:11:37