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 / dbKeyState

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 3rd Jun 2008 20:22
I am using dbKeyState() to get an input from the user.

however i would like the dbKeyState to be triggered ONLY when the user presses AND removes his finger from the key.

Right now if the user presses the key dbKeyState() is being triggered every loop and goes too fast. this is ok for pressing the arrow keys to move a game figure, but not good for toggling weapons, as it cycles too fast!

is there any other type of input I must use instead of dbKeyState() or I must write code to take care of this myself?
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 3rd Jun 2008 21:30
I suggest you work out a timer. You should count the frames, and if its held for a certain amount of frames, it triggers the weapon cycle thing.

I AM THE ALL MIGHTY CORNHOLIO! Do you have TP for my bunghole?
SunDawg
19
Years of Service
User Offline
Joined: 21st Dec 2004
Location: Massachusetts
Posted: 3rd Jun 2008 21:58 Edited at: 3rd Jun 2008 21:58
You could do something like this:



The only problem this presents the time the program will hang, updating the screen but nothing else, while the key is down. A better effect could be done using a boolean variable.


The second system is superior, because the game can continue to function while the key is down.


My site, for various stuff that I make.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 3rd Jun 2008 22:41
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Jun 2008 10:18
thanks a lot SunDawg

Login to post a reply

Server time is: 2024-11-17 17:33:45
Your offset time is: 2024-11-17 17:33:45