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.

Author
Message
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 26th Jul 2008 06:59
I know how to test for key presses, but for my program I need an action to be performed if a key is pressed and then lifted into the up position. Any Help?
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 26th Jul 2008 07:59
This should work.

Ex:
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 26th Jul 2008 09:55
The code works perfectly, but I don't understand select/case/endcase commands. Can someone explain?
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 26th Jul 2008 19:13 Edited at: 26th Jul 2008 19:19
Quote: "but I don't understand select/case/endcase commands"


Quote: " select oldkeypress
case 57 : print "space key let off of" : endcase
case 30 : print "A key let off of" : endcase
case default : "Some other key let off of" : endcase
endselect"


what happens here is that oldkeypress = the keystate here then this acts like a gosub with if and endifs in them so really it's like say


or something close to this but you's would be fully working the a key in this code doesn't work

RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 26th Jul 2008 19:15 Edited at: 26th Jul 2008 19:16
Basically it will test if the Variable after "select" matches one of the "case"s and then executes the code in between "case"/"endcase". If no case matches the Variable it will execute Case Default.

Example: (not tested)


Edit: Too Slow

cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 6th Aug 2008 20:47
I found another solution to my problem...
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 6th Aug 2008 22:07
cguy,

Your code is probably not as versatile. It is only setup for one key(returnkey). Also, your setup will only allow for the code needed, to be executed once, and that's it.
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 7th Aug 2008 19:36 Edited at: 7th Aug 2008 19:45
Nano brain: You are right about my program not being as versatile as yours, but for what it is trying to accomplish in my program, it is perfect. The only key I'm working with is the returnkey, anyway.

Edit: Actually, you are correct by the second part of your post when you said that It could only be run once. That on second thought will not work.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Aug 2008 19:48
Simple to fix that:


cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 9th Aug 2008 05:46
Once again IanM got it... thanks once again!
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 10th Aug 2008 18:12
Use keystate(SCANCODENUMBER)=1 to check for key presses....

cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 11th Aug 2008 06:19
coffeegrunt: that would only check to see if the key is in the down position
Dabbler
17
Years of Service
User Offline
Joined: 3rd Mar 2007
Location: Minnesota
Posted: 16th Aug 2008 05:07
@cguy:

Check this out:

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

I hope it helps.


Whatever...

Login to post a reply

Server time is: 2024-11-15 21:08:25
Your offset time is: 2024-11-15 21:08:25