local lg = assert( love.graphics ) local scene = assert( require 'client.scene' ) local socket = assert( require 'socket' ) local shared = assert( require 'shared' ) local udp = socket.udp() local game = {} local t = 0 local tick = 0 function game.draw() end function game.onPacket( data, msg ) if data then print( data, msg ) end end function game.update( dt ) t = dt + t game.onPacket( udp:receive() ) if t > 0.1 then t = 0 tick = tick + 1 udp:send( tostring(tick) ) end end function game.newGame( ) game.curWorld = shared.NewWorld() --Last world state received from server. game.preWorld = shared.NewWorld() --Current world state predicted by this client. end function game.disconnect( ) return scene.mainmenu() end function game.onLoad( ) udp:settimeout( 0 ) udp:setpeername( "192.168.2.15", 51312 ) end function game.keypressed( key, code, isRepeat ) if code == "escape" then return game.disconnect() end end scene.game = game return game