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 / How do I prevent this?

Author
Message
Lan
16
Years of Service
User Offline
Joined: 8th Sep 2009
Location: Earth
Posted: 27th Aug 2010 16:13
I'm trying to make a Main Menu with a selector. If the downkey is hit, it moves down by a specific number:


But instead, it thinks that I'm holding down the key and it moves straight to 350. How do you prevent this?

[Insert Signature Here]

http://www.LanKingProductions.com/
wyrleywolves
23
Years of Service
User Offline
Joined: 6th May 2003
Location:
Posted: 27th Aug 2010 16:18
if scancode()=0 then rep=0
If DownKey()=1 and cursorPosition#<350 and rep=0
rep=1
cursorPosition#=cursorPosition#+100
endif
Its just key repeating..This is a simple way to stop it
Syncaidius
21
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 27th Aug 2010 16:21 Edited at: 27th Aug 2010 16:25
@Lan:
All You're really missing is a toggle variable:


Hope this helps.

Lan
16
Years of Service
User Offline
Joined: 8th Sep 2009
Location: Earth
Posted: 27th Aug 2010 16:25 Edited at: 27th Aug 2010 16:37
What is the point of downPressed = 1 if you just make it 0 again?

EDIT: now I feel stupid. I was reading the else as an endif

[Insert Signature Here]

http://www.LanKingProductions.com/
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 27th Aug 2010 16:36
That way the statement can't be executed until you stop pressing the key because while downPressed = 1 the statement can't be executed.

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

wyrleywolves
23
Years of Service
User Offline
Joined: 6th May 2003
Location:
Posted: 27th Aug 2010 16:37
What is the point of downPressed = 1 if you just make it 0 again?
It will only be 0 when downkey()=0, therefore prevents it key repeating.

Login to post a reply

Server time is: 2026-07-23 12:10:40
Your offset time is: 2026-07-23 12:10:40