Guest User

Untitled

a guest
Dec 23rd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. host = CreateGNetHost()
  2. port = 21231
  3.  
  4. listen = GNetListen( host, port )
  5. Local remoteobj:TGNetObject
  6.  
  7. objlist:TList = New TList
  8.  
  9. Type player
  10.     Field id
  11.     Field x
  12.     Field y
  13.     Field remoteobj
  14. EndType
  15.  
  16. playerlist:TList = New TList
  17.  
  18. Graphics 800, 600
  19.  
  20. While Not (KeyHit(KEY_ESCAPE) Or AppTerminate ())
  21.     Delay 10
  22.    
  23.     GNetSync host
  24.    
  25.     objlist = GNetObjects( host, GNET_CREATED )
  26.     For remoteobj = EachIn objlist
  27.         pro = GetGNetInt ( remoteObj, 0 )
  28.         pro2 = GetGNetInt ( remoteObj, 1)
  29.         player1:player=New player
  30.         player1.id=pro2
  31.         player1.x=0
  32.         player1.y=0
  33.         playerlist.AddLast (player1)
  34.         player1.remoteobj=CreateGNetObject (host)
  35.         SetGNetInt (player1.remoteobj,0,player1.id)
  36.     Next
  37.    
  38.     objlist = GNetObjects (host, GNET_MODIFIED)
  39.     For remoteobj = EachIn objlist
  40.         xm = GetGNetInt ( remoteobj, 2 )
  41.         ym = GetGNetInt ( remoteobj, 3)
  42.         id = GetGNetInt ( remoteobj, 1)
  43.         SetGNetInt ( remoteobj, 2, 0)
  44.         SetGNetInt ( remoteobj, 3, 0)
  45.        
  46.         For player1 = EachIn playerlist
  47.             If id=player1.id
  48.                 player1.x=player1.x+xm
  49.                 player1.y=player1.y+ym
  50.                 SetGNetInt (remoteobj,4,player1.x)
  51.                 SetGNetInt (remoteobj,5,player1.y)
  52.                 SetGNetInt (player1.remoteobj,2,player1.x)
  53.                 SetGNetInt (player1.remoteobj,3,player1.y)
  54.                 Exit
  55.             EndIf
  56.         Next
  57.         DrawText ("getting data",1,1)
  58.     Next
  59.    
  60.     i=0
  61.     For player1 = EachIn playerlist
  62.         DrawText (player1.id,1,i*100+20)
  63.         DrawText (player1.x,1,i*100+40)
  64.         DrawText (player1.y,1,i*100+60)
  65.         i=i+1
  66.     Next
  67.    
  68.     Flip
  69.     Cls
  70. Wend
  71. CloseGNetHost(host)
  72. End
Add Comment
Please, Sign In to add comment