Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- host = CreateGNetHost()
- port = 21231
- listen = GNetListen( host, port )
- Local remoteobj:TGNetObject
- objlist:TList = New TList
- Type player
- Field id
- Field x
- Field y
- Field remoteobj
- EndType
- playerlist:TList = New TList
- Graphics 800, 600
- While Not (KeyHit(KEY_ESCAPE) Or AppTerminate ())
- Delay 10
- GNetSync host
- objlist = GNetObjects( host, GNET_CREATED )
- For remoteobj = EachIn objlist
- pro = GetGNetInt ( remoteObj, 0 )
- pro2 = GetGNetInt ( remoteObj, 1)
- player1:player=New player
- player1.id=pro2
- player1.x=0
- player1.y=0
- playerlist.AddLast (player1)
- player1.remoteobj=CreateGNetObject (host)
- SetGNetInt (player1.remoteobj,0,player1.id)
- Next
- objlist = GNetObjects (host, GNET_MODIFIED)
- For remoteobj = EachIn objlist
- xm = GetGNetInt ( remoteobj, 2 )
- ym = GetGNetInt ( remoteobj, 3)
- id = GetGNetInt ( remoteobj, 1)
- SetGNetInt ( remoteobj, 2, 0)
- SetGNetInt ( remoteobj, 3, 0)
- For player1 = EachIn playerlist
- If id=player1.id
- player1.x=player1.x+xm
- player1.y=player1.y+ym
- SetGNetInt (remoteobj,4,player1.x)
- SetGNetInt (remoteobj,5,player1.y)
- SetGNetInt (player1.remoteobj,2,player1.x)
- SetGNetInt (player1.remoteobj,3,player1.y)
- Exit
- EndIf
- Next
- DrawText ("getting data",1,1)
- Next
- i=0
- For player1 = EachIn playerlist
- DrawText (player1.id,1,i*100+20)
- DrawText (player1.x,1,i*100+40)
- DrawText (player1.y,1,i*100+60)
- i=i+1
- Next
- Flip
- Cls
- Wend
- CloseGNetHost(host)
- End
Add Comment
Please, Sign In to add comment