Лабораторная работа: Greating game on visual basic with multiplayer system

Dim x As Integer

Dim objDPEnumPlayers As DirectPlayEnumPlayers

Dim SessionData As DirectPlaySessionData

' Enumerate players

On Error GoTo ENUMERROR

Set objDPEnumPlayers = dxplay. GetDPEnumPlayers ("", 0)

gNumPlayersWaiting = objDPEnumPlayers. GetCount

' Update label

Set SessionData = dxplay. CreateSessionData

Call dxplay. GetSessionDesc (SessionData)

StatusMsg = gNumPlayersWaiting & " of " & SessionData. GetMaxPlayers _

& " players ready..."

Label8. Caption = StatusMsg

If gNumPlayersWaiting = SessionData. GetMaxPlayers And usermode = "host" Then

start. Enabled = True

Label8. Caption = "Everyone is here Click Start"

End If

If gNumPlayersWaiting = SessionData. GetMaxPlayers And usermode = "client" Then

start. Enabled = False

Label8. Caption = "Waiting For Host To Start Session"

End If

' Update listbox

Dim PlayerName As String

For x = 1 To gNumPlayersWaiting

PlayerName = objDPEnumPlayers. GetShortName (x)

If PlayerName <> playersname. Text Then

labeljoined. Caption = PlayerName & " has joined the game."

opponentsname = PlayerName

End If

К-во Просмотров: 840
Бесплатно скачать Лабораторная работа: Greating game on visual basic with multiplayer system