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 / Input with a qwerty keyboard

Author
Message
Game designer extraordinaire
13
Years of Service
User Offline
Joined: 11th Oct 2010
Location: Mars
Posted: 17th Oct 2010 20:44
Hello again, its me, Game designer extraordinaire. And today I am having a problem. You see I\'m trying to get input from several keys, such as z , q,f,d,j, and so on. The problem is dont know how to check for the input in dark basic pro. If anyone can help me please do. Thanks in advance

Yes...it is I
bergice
16
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 17th Oct 2010 23:39 Edited at: 17th Oct 2010 23:40
Use the keystate command.

You can use the official new IDE's Keystate Helper to find keystates.

51fa1db0ec7c4af52d93a6f5d0e86bc5
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 18th Oct 2010 01:28
Quote: "You can use the official new IDE's Keystate Helper to find keystates."


Or the Keystate Map I made a long time ago.



Game designer extraordinaire
13
Years of Service
User Offline
Joined: 11th Oct 2010
Location: Mars
Posted: 18th Oct 2010 01:53
Quote: "
Or the Keystate Map I made a long time ago."

Thanks! Only one question *again* How would I implement this?

Yes...it is I
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 18th Oct 2010 14:21 Edited at: 18th Oct 2010 14:21


pcRaider
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 18th Oct 2010 14:27
You read helpfile of a KEYSTATE command.
You push a [F1]key and look for it.
You may watch a sample code.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Oct 2010 15:16
You can also get the key code with scancode()

So let's say you want to check W,A,S,D, you'd check what code each of the keys have:

w=17
a=30
s=31
d=32

so:



TheComet

TuPP3
17
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 18th Oct 2010 15:32 Edited at: 18th Oct 2010 15:40
Another simple and fast way is to use:


You can use that with letters, characters and numbers but not keys like Enter, CTRL, Backspace etc.
But AFAIK it returns only one key at a time, so when W and D is pressed at the same time, it will only detect the last key pressed.

It's not good for movement or things where you might need to hold 2 or more keys at the same time, but simpler for example trigger buttons like reloading.

There are also some neat functions for the main keys to make the code more readable, like:
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Oct 2010 07:57
Quote: "Thanks! Only one question *again* How would I implement this?"


Just like everybody that posted after your last post.



Most people add =1 after any KEYSTATE command in an IF/THEN check. I don't because Darkbasic Pro automatically assumes that you want to check for the key being pressed "if keystate(keystate number)=1" without actually typing in the =1 in code. You only really need the equals sign after a KEYSTATE IF/THEN check if you want to check for the key not being pressed "if keystate(keystate number)=0".

sneaky smith12
17
Years of Service
User Offline
Joined: 30th Apr 2006
Location: Like id tell you, oh wait i just did
Posted: 20th Oct 2010 03:09
Quote: "Or the Keystate Map I made a long time ago."


Godsend.

If at first you dont succeed, LOWER YOUR STANDARDS.
Game designer extraordinaire
13
Years of Service
User Offline
Joined: 11th Oct 2010
Location: Mars
Posted: 26th Oct 2010 04:00
Thanks Everyone!
You just allowed me to finish a game i'm making.

Yes...it is I
Beyond the Humans Knowledge
13
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 1st Nov 2010 16:44
Like how TheComet posted, use the keystate() commands so you can move diagonally.

onhcet d(-_-)b techno

Login to post a reply

Server time is: 2024-04-28 19:09:51
Your offset time is: 2024-04-28 19:09:51