Лабораторная работа: Greating game on visual basic with multiplayer system
Set EnumSession = Nothing
Set dxplay = Nothing
End Sub
' Main procedure. This is where we poll for DirectPlay messages in idle time.
Public Sub Main ()
MainBoard. Show
Do While DoEvents () ' allow event processing while any windows open
DPInput
Loop
End Sub
' Receive and process DirectPlay Messages
Public Sub DPInput ()
Dim FromPlayer As Long
Dim ToPlayer As Long
Dim msgsize As Long
Dim msgtype As Long
Dim dpmsg As DirectPlayMessage
Dim MsgCount As Long
Dim msgdata () As Byte
Dim x As Integer
Dim fromplayername As String
If dxplay Is Nothing Then Exit Sub 'IF single player then exit
On Error GoTo NOMESSAGE
' If this call fails, presumably it's because there's no session or
' no player.
MsgCount = dxplay. GetMessageCount (MyPlayer) 'Get number of messages.
On Error GoTo MSGERROR
Do While MsgCount > 0 'Read all messages
Set dpmsg = dxplay. Receive (FromPlayer, ToPlayer, DPRECEIVE_ALL) 'Read DXINput