|
-
Sep 11th, 2000, 02:15 PM
#1
Thread Starter
Fanatic Member
And one more thing, guys:
Is there any way to do many players playing?
I mean for example:
Player one holds the right arrow to move,
and Player two holds his move key.
Does this possible in VB?
In my way it shows that it can't be.
If you have a way, tell me, please...
Thank you anyway,
Arie.
Visit: http://www.nip.to/camel2000
-
Sep 12th, 2000, 11:30 AM
#2
Frenzied Member
I haven't seen your way, so I'm going to make some assumptions about this.
If each player is an object, you can add the players to a collection, and then have a For Each...Next loop inside/outside your main game loop, so that each player is given a turn. Assign the player's control keys as true or false in an array of booleans (a member variable of the player object, or somewhere within the object model of a player) which flag each of the player's control keys as up or down. Set them to true on the KeyDown event and False on the KeyUp Event.
How's that? I haven't actually done anything like this before but I'm guessing that would work
Harry.
"From one thing, know ten thousand things."
-
Sep 12th, 2000, 03:12 PM
#3
If you are referring to multiple keypresses, then GetAsyncKeyState will do the trick.
Add the following code to a Form with 2 PictureBoxes and a Timer. (I am assuming that player1 uses the Up Arrow key to move and player2 uses W to move)
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
'Move player1
If GetAsyncKeyState(vbKeyUp) Then Picture1.Top = Picture1.Top - 10
'Move player2
If GetAsyncKeyState(vbKeyW) Then Picture2.Top = Picture2.Top - 10
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|