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 / Slow down key repeat rates?

Author
Message
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 6th Nov 2010 02:21
so i have the code below in my main loop, it works fine but it repeats two fast, i want it to ether not repeat so +1 every key press, or for it to have like a 1 sec delay before the next +1 to var.

any help is appreciated greatly!


Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 6th Nov 2010 02:28
Here's the method with on keypress at a time


Here's the code for the timed one


My computer surpasses all the technologies of the day. What computer do I have?

Teh Stone
16
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 6th Nov 2010 02:28

works for now but quite a messy way really,
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 6th Nov 2010 02:29
thanks for the quick response! trying now...
Eminent
16
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 6th Nov 2010 02:31 Edited at: 6th Nov 2010 02:32
Put a "Wait 1000" In the loop? Or

Dunno if that works though. You'd be suprised how bad a programmer I am(really really bad).
EDIT: Wow you guys type fast 0.o.


Teh Stone
16
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 6th Nov 2010 02:33
good lemme no if it works
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 6th Nov 2010 02:35 Edited at: 6th Nov 2010 02:37
thanks Madscientist it worked! Eminent, i thought of that too but its critical that the main loop can run as fast as possible just the key press rate needs to be slowed.
thanks all others for quick responses!
Eminent
16
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 6th Nov 2010 03:07
The timer one still lets it run as fast as possible.


Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 6th Nov 2010 03:34
Quick Example of timer.



Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Nov 2010 09:13
I always do timers like this:



Use the up and down arrow keys to increase/decrease var and use the + and - signs on the number keypad to increase/decrease the delay. The delay is the milliseconds to wait before allowing a keypress. 1000 milliseconds = 1 second.

SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 6th Nov 2010 23:52
The code by mad scientist has been implemented here:

http://forum.thegamecreators.com/?m=forum_view&t=177511&b=6

Login to post a reply

Server time is: 2026-07-26 06:34:46
Your offset time is: 2026-07-26 06:34:46