Advertisement
Auios

Untitled

Sep 16th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define fbc -s gui
  2.  
  3. #include "header.bas"
  4.  
  5. screenres scrnx,scrny,8
  6.  
  7. dim as ClientData me,OldMe
  8. dim as ClientData cl(MaxClients)
  9. dim as ClientData OldCl(MaxClients)
  10. dim as ServerData sv
  11.  
  12. print "Attempting to connect to host..."
  13.  
  14. var MyIP = hResolve(HostIP)
  15.  
  16. var iResu = hConnect(ServerSocket,MyIP,ServerPort) 'socket/ip/port
  17. if iResu then
  18.     print "Connected..."
  19. else
  20.     print "Connection failed..."
  21.     sleep:stop
  22. end if
  23.  
  24. hReceive(ServerSocket,cast(any ptr,@me), sizeof(me))
  25. for i as integer = 1 to MaxClients
  26.   cl(i).slot = -1: oldcl(i).slot = -1
  27. next i
  28.  
  29. do
  30.    
  31.     static as double dSvFps
  32.     if abs(timer-dSvFps) > 1 then
  33.       dSvFps = timer
  34.     else
  35.       if (timer-dSvFps) > 1/svfps then          
  36.         hSend(ServerSocket, cast(any ptr,@me), sizeof(me))            
  37.         with me
  38.           if multikey(sc_lshift) then
  39.               if multikey(sc_w) then .y-=9
  40.               if multikey(sc_s) then .y+=9
  41.               if multikey(sc_a) then .x-=9
  42.               if multikey(sc_d) then .x+=9
  43.           else
  44.               if multikey(sc_w) then .y-=3
  45.               if multikey(sc_s) then .y+=3
  46.               if multikey(sc_a) then .x-=3
  47.               if multikey(sc_d) then .x+=3
  48.           end if
  49.         end with            
  50.       end if          
  51.     end if
  52.    
  53.     if hSelect(ServerSocket) then        
  54.       var iResult = hReceive(ServerSocket,cast(any ptr,@sv), sizeof(sv))
  55.       if iResult then
  56.         for i as integer = 1 to MaxClients
  57.           cl(i).slot = -1
  58.         next i
  59.         for i as integer = 1 to sv.ConnectedClients-1
  60.             dim as ClientData tTempCli
  61.             iResult = hReceive(ServerSocket,cast(any ptr,@tTempCli), sizeof(tTempCli))
  62.             if iResult <= 0 then exit for
  63.             cl(tTempCli.slot) = tTempCli            
  64.         next i
  65.       end if      
  66.       if iResult <=0 then
  67.         print "Disconnected"
  68.         hClose(ServerSocket)
  69.         sleep: stop
  70.     end if
  71.      
  72.     end if
  73.        
  74.     screenlock
  75.       line(0,0)-(scrnx,scrny),0,bf
  76.       for CNT as integer = 1 to MaxClients
  77.         if cl(CNT).Slot <> -1 then
  78.           if oldCl(CNT).Slot <> cl(CNT).Slot then
  79.             OldCl(CNT) = cl(CNT)
  80.           else
  81.             with oldCl(CNT)
  82.               .x = (.x+cl(CNT).x) shr 1
  83.               .y = (.y+cl(CNT).y) shr 1
  84.               circle(.x,.y),15,15
  85.             end with
  86.           end if
  87.         end if
  88.       next CNT
  89.      
  90.       with OldMe
  91.         .x = (.x+me.x) shr 1
  92.         .y = (.y+me.y) shr 1
  93.         circle(.x,.y),15,10
  94.       end with
  95.      
  96.     screenunlock
  97.    
  98.     static as double dSync
  99.     if abs(timer-dSync) > .5 then
  100.       dSync = timer
  101.     else
  102.       while (timer-dSync) < 1/60
  103.         sleep 1,1
  104.       wend
  105.       dSync += 1/60
  106.     end if
  107.    
  108.     do    
  109.       var sKey = inkey()
  110.       if len(sKey) then
  111.         var iKey = cint(sKey[0])
  112.         if iKey=255 then iKey = -sKey[1]
  113.         select case iKey
  114.         case 27,asc("q"),asc("Q"): exit do,do 'Quit
  115.         end select
  116.       else
  117.         exit do
  118.       end if
  119.     loop
  120.    
  121. loop
  122.  
  123. hClose(ServerSocket)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement