Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Client = NetTest:addState('Client')
- function Client:enterState()
- clearLoveCallbacks()
- cursors = {}
- mouse = {}
- mouse.x = 0
- mouse.y = 0
- mouse.xp = -1
- mouse.yp = -1
- print("initializing client")
- function onReceive(data)
- print("recieved " .. data)
- --cursors = lube.bin:unpack(data)
- end
- client = lube.client()
- client:setHandshake("Hi!")
- client:setCallback(onReceive)
- client:connect("127.0.0.1", 18025)
- print("initialized client")
- function love.update(dt)
- client:update(dt)
- mouse.x, mouse.y = love.mouse.getPosition()
- if mouse.x ~= mouse.xp and mouse.y ~= mouse.yp then
- client:send(lube.bin:pack(mouse))
- end
- mouse.xp = mouse.x
- mouse.yp = mouse.y
- end
- function love.draw()
- for _,i in ipairs(cursors) do
- love.graphics.circle("fill", i.x,i.y, 10, 64)
- end
- end
- function love.keypressed(k)
- if k=='escape' then
- netTest:gotoState('Menu')
- end
- end
- function love.quit()
- client:disconnect()
- end
- end
- function Client:exitState()
- client:disconnect()
- print("Exiting client")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement