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 / Multiple keys pressed

Author
Message
047
18
Years of Service
User Offline
Joined: 4th Jun 2006
Location:
Posted: 3rd Jul 2006 17:45
Hi,
How do you tell the computer to do something if more than 1 key is being pressed at the same time. I'm working on a car racing game where "a" accelerates and the arrow keys steer. The problem is that the car is supposed to slow down if "a" is not pressed. However everytime I press the arrow keys to steer while still pressing "a" the car slows down because apparently INKEY$() <> "a" anymore. I studied the "CAVERUN" demo that comes with DB classic and they seem to be using the same method I'm attempted but you can accelare and steer at the same time.
Any ideas?
Thanks a lot!!!
Game Man
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location:
Posted: 4th Jul 2006 00:11 Edited at: 4th Jul 2006 14:51
The demo uses "Upkey()", "Leftkey()", and "Rightkey()". "Inkey$" only returns the string of a letter key. You can also use "Scancode()" which returns a numeric value of any key pressed.

Scancode() and Inkey$ can only return one value.

Look in the help files for all the key functions.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Jul 2006 00:12 Edited at: 4th Jul 2006 00:14
Look up SCANCODE() in the help Use it with KEYSTATE() to check all keys



CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 4th Jul 2006 00:14
and remember there is a hardware limitation of how many simultaneous keys that will register with the system as being pressed, so dont try and use too many keys at one time.

Science, Mathematics, and Physics do not lie - only people do.

Login to post a reply

Server time is: 2024-11-27 15:31:50
Your offset time is: 2024-11-27 15:31:50