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.

Newcomers DBPro Corner / How to clear keyboard buffer? Keypresses are too quick

Author
Message
Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 30th Sep 2008 13:02
My keyboard is responding too quickly (or DBP is storing the input for a fraction too long), so I'm hoping there's a way I can clear out the buffer.

As my game starts, a splash screen is displayed, and I use the following code to advance:


This will wait just over 4 seconds, or for any key press or any mouse click before moving on and displaying the menu. In the menu I have this code to detect a press of the space bar to start the game:


If I click the mouse or press any key apart from the space bar when the splash screen is displayed, I get to the menu. If I use the space bar to advance the splash screen, it clears the splash screen, whips me through the menu and straight into the first screen of my game.

I don't really want to insert an artificial wait between the menu appearing and when keypresses are recognised, but there must be a way to stop DBP accepting a key press on the splash screen and actioning it on the menu screen.
RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 30th Sep 2008 14:18
you could simply use this before your menu:

Repeat : Until Keystate(57)=0

to wait until space is released. i dont think anyone would notice it because you normally dont hold down the key

Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 30th Sep 2008 14:21
Still seems a little kludgy, but it works - thanks
DMM
16
Years of Service
User Offline
Joined: 11th Sep 2008
Location:
Posted: 3rd Oct 2008 07:15
I'm not sure if I completely understand what your program is doing but this code will check for a spacebar press but wont do anything until its released, and wont repeat until its been released and presed again either. Hope it helps.


Login to post a reply

Server time is: 2024-11-15 22:16:32
Your offset time is: 2024-11-15 22:16:32