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 / Keyboard keys problem!

Author
Message
dmcdaid
16
Years of Service
User Offline
Joined: 12th Mar 2010
Location:
Posted: 12th Mar 2010 12:11
I was wondering if anyone would be able to help me with my Game project?

I'm creating a 'Guitar Hero'-like game, where notes fall and you must hit them as they reach a point at the bottom of the screen. I've pretty much finished.

However, how would i go about setting the F1, F2, F3 and F4 keys as the keys the user would have to press in order to hit the notes.

Right now i am using the up, down, left and right keys but this is extremely impractical...

Please help!
HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 12th Mar 2010 12:41
scancode will give you a number which you can check to see which F keys as been press, below demo code from help file.



Dark Physics makes any hot drink go cold.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Mar 2010 13:40
You should use scankeys to figure out what the F1 - F4 keys are:

Do
cls
text 0,0,str$(scancode())
sync
Loop

Run that and take a note of any code for a key that you want to use.

Then, with those codes, use Keystate instead of scankeys()

If keystate(f1ID)=1 then blah blah blah

And this means that you can have all 4 keys checked at the same time - scancode does not let you do that, neither does inkey$. So, for the keyboard always use keystate when you need more than one key at a time.

Also, consider the USB guitars for GH2 and RockBand - supporting one of those would be great - I could figure out the controls for you and make a little code snippet if you don't have one. It is ok to grab the keyboard and use the F keys, but if people see that they can use a guitar as well, then they would appreciate your game a lot more I think.


Health, Ammo, and bacon and eggs!
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 12th Mar 2010 14:03 Edited at: 12th Mar 2010 14:04
Someone made this keyboard pic a long time ago. It gives you the scancodes. It's handy to print it out and refer to it.



dmcdaid
16
Years of Service
User Offline
Joined: 12th Mar 2010
Location:
Posted: 16th Mar 2010 12:58
Thanks a lot guys! Got it sorted - everythings working great!

Login to post a reply

Server time is: 2026-07-26 23:39:59
Your offset time is: 2026-07-26 23:39:59