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 / how to check the keys of....keys like q,1h,3,4,h,c and not spacekey() and stuff

Author
Message
freak_oz
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: castricum
Posted: 21st Sep 2004 02:42
read the title but for the non readers:
how to check an key like a or q or 4 or 7 how?
spacekeys and stuff are easy just do

thx
freak_oz

uhum....
Dot Merix
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Canada
Posted: 21st Sep 2004 02:46
You can use inkey for letters..

Ie..

if upper$(inkey$()) = "W"
move object up 1,1
endif

for example.

- Merix

WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
freak_oz
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: castricum
Posted: 21st Sep 2004 02:47
thx
i knew that from the normal basic but i didnt know you cna use it
here to
freak_oz

uhum....
Dot Merix
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Canada
Posted: 21st Sep 2004 02:50
Sure can

numbers will work this way...

Do something like..

if inkey$() = "7"
print "hello"
endif

- Merix

WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 21st Sep 2004 04:23
Also consider scancode and keystate. These commands are your friends for keyboard input.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
Dodo
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: eating lunch
Posted: 21st Sep 2004 05:15
Adding on to what phil said, the values for the keys can be found here. You would then use them as follows:





both of these examples would return a one if "w" is pressed. Hope this helps

Dot Merix
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Canada
Posted: 21st Sep 2004 07:02
My ways still easier

- Merix

WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Turoid
20
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 21st Sep 2004 21:09
yes but keystate works better in games..

Do you need a complete FPS engine ?? well here it is:
http://forum.thegamecreators.com/?m=forum_view&t=38869&b=6&p=0
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 21st Sep 2004 21:12
Quote: "if scancode(17)=1 then ..."


I think that should be
If scancode()=17 then ...


The word "Gullible" cannot be found in any English Dictionary.
Dodo
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: eating lunch
Posted: 22nd Sep 2004 05:21
oh yeah oops. I normally use keystate()

Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 22nd Sep 2004 06:09
A good tip for beginners is that when programming complex games its sensible to have a function which checks the keystate of each key each loop and then saves the result in a variable. You then check the value in the variable using an if/then to decide what action to take later. This saves more than one check of the keyboard state each game loop.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 30th Sep 2004 04:33
This is how I do it

#CONSTANT up = 118
#CONSTANT down = 119

#CONSTANT True = 1
#CONSTANT False = 0

IF KEYSTATE(up) = True

I like KEYSTATE, because you can have multiple keys held down at one time and it doesn't freak like INKEY$() would.

I also assign True and False, to 1 and 0, because it's easier to remember that way and it's a neater layout when your looking through mountains of code.

Oh ya, and Up and Down may not have the right numbers assigned to them, because I can't remember what they are off hand..

I usually have another program handy for checking scancodes.. the program is as follows..

SYNC ON
HIDE MOUSE

DO
CLS
PRINT SCANCODE()
FASTSYNC
LOOP

Login to post a reply

Server time is: 2024-09-23 01:14:23
Your offset time is: 2024-09-23 01:14:23