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 / Pressing letters to perform actions

Author
Message
Kingy
19
Years of Service
User Offline
Joined: 25th Oct 2004
Location:
Posted: 8th Nov 2004 22:12
Simple question, whats the code to press say "q" on the keyboard to quit a program? is it something like if inkey()=q then exit?
GameKit
21
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 8th Nov 2004 22:44
You could use "If inkey()="q" Then Exit" like you said, but that only lets you press one key at a time (so its not very good for game controls).
I would recommend you use the keystate() command. Each key on your keyboard has a unique key number assigned to it. Spacekey is 57 if I remember correctly. To find out which keys have which values place this code in your main loop.
"Print Scancode()"
This will print the current key number being pressed on the screen. Just press the keys you need to know and write down the numbers...
After that, use keystate in your code to get it to recognize what keys are being pressed...
"If Keystate(57)=1 Then [Fire Bullet]" Will fire the bullet when you press the spacekey.

Well... I hope I helped...


The computer isn't an addiction, its more of a mental and social dependancy.
Kingy
19
Years of Service
User Offline
Joined: 25th Oct 2004
Location:
Posted: 8th Nov 2004 23:20
Yeh great helps thanks alot. Works a treat.

Login to post a reply

Server time is: 2024-09-23 04:17:54
Your offset time is: 2024-09-23 04:17:54