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 / wasd and enter problem

Author
Message
flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 29th Mar 2006 04:50
IM making a game with 2 players. One personb uses wasd, and the control key, and the other usues the arrowkeys and the returnkey
BUT! when the returnkey is pressed, the other guy cant move his guy around. I dirst tried to put the wasd control in the if returnkey()=1 statment with the arrowkey controls, but that didnt work. SO then i made this.

this told me that thr returnkey had a scancode value of 28!!! so that why putting the wasd control in with diidnt work. Because they each have there own scancode #. Then i tried

but that didnt work either. I tried many variations on that one. DOes anyone have any ideas has to how get past this problem.

dont assume cause ull make an ass out of you and me!
SirFire
19
Years of Service
User Offline
Joined: 4th Apr 2005
Location: North America
Posted: 29th Mar 2006 06:01
You are trying to do things with the keyboard that it was not designed to do. There is a hardware limitation on the number of keys that can be pressed at once, and also pressing a key overrides any other key that is being pressed.

Go pick up a couple of usb gamepads.

master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 29th Mar 2006 08:52
Quote: "You are trying to do things with the keyboard that it was not designed to do. There is a hardware limitation on the number of keys that can be pressed at once, and also pressing a key overrides any other key that is being pressed."

Only for scancode() my friend. If you use keystate() it works much better, and you can use multiple keys at the same time.

Use these codes for movement:
W: if keystate(17)=1 then do whatever w does
S: if keystate(31)=1 then do whatever s does
D: if keystate(32)=1 then do whatever d does
A: if keystate(30)=1 then do whatever a does
Enter Key if returnkey()=1 then do whatever it does
Control Key if controlkey()=1 then do whatever it does
Arrow keys - if upkey()=1 then ....
if downkey()=1 then ...
if rightkey()=1 then ...
if leftkey()=1 then ...

That should help you quite a bit,

Good luck

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Mar 2006 13:26 Edited at: 29th Mar 2006 13:27
master programmer ... you are mistaken!

What SirFire said is absolutely correct. There is a hardware limit on the amount of keys that can be pressed simultaneously. It depends which keys you are pressing but it can be anything from 3 - 6.


flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 29th Mar 2006 22:48
THANK YOU MASTER P!!! I tried it and it worked! YES now my friends wont be disappointed. tiss very annoying when somone was attacking you and you could move...

dont assume cause ull make an ass out of you and me!
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 29th Mar 2006 23:43
Get a ZBoard. 32 Keys at once.


At least farting ferrets are better than stinky stoats.
flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 31st Mar 2006 00:12
for the moment, what i need i can do with my standerd compaq keyboard.



"Jesues never sleeps when your beeing a sinner"

dont assume cause ull make an ass out of you and me!
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 31st Mar 2006 07:23 Edited at: 31st Mar 2006 07:23
What I meant was that you can detect for more keys being pressed by using keystate(), rather than only being able to detect one using scancode().

np, glad I could help

Login to post a reply

Server time is: 2024-11-27 22:33:45
Your offset time is: 2024-11-27 22:33:45