Advertisement
electronic_steve

client test

Feb 13th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. -- client.lua
  2. require "enet"
  3. local host = enet.host_create()
  4. local server = host:connect("62.165.46.67:6789")
  5. gs=love.graphics
  6. pingtimedraw=0
  7. dl2=""
  8. pingtime=0
  9. function love.update(dt)
  10.  
  11.  local event = host:service(100)
  12.   if event then  
  13.     if event.type == "connect" then
  14.    
  15.  
  16.  
  17.      event.peer:send("connected")
  18.     elseif event.type == "receive" then
  19.    
  20.        if pingtime==0 then
  21.       event.peer:send("ping")
  22.       pingtime=pingtime+dt
  23.       else
  24.       pingtime=pingtime+dt end
  25.       if   event.data=="pong" then
  26.       pingtimedraw=pingtime
  27.       pingtime=0 end
  28.     end
  29.   end
  30. end
  31. function love.draw()
  32. gs.setColor(255,255,255)
  33.  gs.print("client!",10,10)
  34.  
  35.  gs.print(pingtimedraw,10,50)
  36.  
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement