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 / Why do i have to hold down a key for it to respond

Author
Message
jaykav99
15
Years of Service
User Offline
Joined: 30th Jul 2009
Location:
Posted: 6th Aug 2009 21:57
Id like to use the return key to start the game but the game doesnt load unless i hold the key in. Id like to be able to just click it once and let it go.

[/code]IF returnkey()=1
stop sound 1
stop sound 2
stop sound 3
gosub _gameload
endif[code]
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Aug 2009 23:02 Edited at: 6th Aug 2009 23:08
Are you sure it's not loading when you tap return?

Try tapping return with this code. It'll show how many times it GOSUBS to that label.



Now to actually only load it once you need a switch. You check for the return key and look for the switch being off (zero) then turn the switch on (one) so it's not loaded again.



You could also use the KEYSTATE() command but it works just like RETURNKEY().



You can use this as a reference of all the keystate numbers: http://mysite.verizon.net/grueslayer/Keystate.png

By the way you got the code snips backwards... / should be on the bottom.

chwilly
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location:
Posted: 7th Aug 2009 05:02
Wait until the return key is released before doing to stop sound and gosub commands.

IF returnkey()=1

repeat: until returnkey() = 0

stop sound 1
stop sound 2
stop sound 3
gosub _gameload

endif

Login to post a reply

Server time is: 2024-11-24 04:22:02
Your offset time is: 2024-11-24 04:22:02