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.

DarkBASIC Professional Discussion / disable pressing the key twice

Author
Message
younis12
16
Years of Service
User Offline
Joined: 23rd Feb 2010
Location:
Posted: 14th Feb 2011 16:25
hello again

i have a problem
how i can press a button but when i pressed the button(the key that i pressed is in active until the action is over)

my action her is jumping

i have made my simple code for if sapcekey is pressed then move object up 5
and if the object position = the old position plus 5 then move object down 5

but this cant happen because if you pressed space key two times it will fly
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 14th Feb 2011 16:48 Edited at: 14th Feb 2011 16:49
You could do it like this. The object will no longer 'fly', because the program waits untill the spacebar has been released after pressing.
This code should be inside your main loop.



Cheers

SLAYER RULES! YEAH, MAN!!
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Feb 2011 19:39
You use a switch. You check for the spacebar and the switch being off (Jump=0) and turn it on. Then you turn off the switch when the jump is finished.

This uses a timer to automatically end the jump in 2 seconds:


Login to post a reply

Server time is: 2026-07-16 04:36:04
Your offset time is: 2026-07-16 04:36:04