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 Discussion / 2 Player Control

Author
Message
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 6th May 2004 20:58
How do you make 2 player controls?
eg.
Player1:-
Forward = Up arrow
Backward = Down arrow
Right = Right arrow
Left = Left arrow
Player2:-
Forward = w
Backward = s
Right = d
Left = a
If you use:
if inkey$()="w" then move object 2,2
then as soon as any other key is pressed it stops working.
How do I get around this?

Current Projects: Dark_Worlds_Map_Editor version0.1 [email protected]
GameKit
22
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 6th May 2004 21:06 Edited at: 6th May 2004 21:09
Instead of Inkey$() use Keystate()... To find the numbers to use for each of the keystates put this code near the top of your main loop...

Set Cursor 0,0
Print Scancode()

...Now, while playing the game, press a key and remember the number that appears at the top left of your screen...For Example, pressing the "A" button give you the number 30... The "UP" key would give you the number 200...

Now just write...

If keystate(200)=1 then [accelerate player 1]

...well... I hope I helped...

To save you some trouble, here are the rest of the keystates...



Previously known as "Game_Creator". Thou shalt not thwart the way of the dragon. For thou tasteth like chicken.
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 7th May 2004 21:22
Thanks!
Just worked that one out!

Current Projects: Dark_Worlds_Map_Editor version0.1 [email protected]

Login to post a reply

Server time is: 2025-05-23 13:39:55
Your offset time is: 2025-05-23 13:39:55