Basic basic loop

This commit is contained in:
wan-may 2023-09-04 15:56:14 -03:00
parent beb5d71f03
commit 51a0bcbdb8
4 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,33 @@
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
local currentWorld = shared.NewWorld()
function game.draw()
end
function game.update( dt )
t = dt + t
if t > 0.1 then
t = 0
tick = tick + 1
local s = string.format("client: %d", tick)
print( s )
udp:send( s )
end
end
function game.onLoad( )
udp:settimeout( 0 )
udp:setpeername( "192.168.2.15", 51312 )
end
return scene.add( game, 'game' )

View File

@ -50,7 +50,9 @@ function menu.mousemoved( x, y, dx, dy, istouch )
end
function menu.mousepressed( x, y, button, istouch, presses )
scene.load( 'browser' )
if button == 1 then scene.load( 'browser' )
else scene.load( 'game' )
end
end
function menu.keypressed( key, code, isrepeat )

View File

@ -6,5 +6,6 @@ function love.load()
local scenes = assert( require 'client.scene' )
assert( require 'client.menu' )
assert( require 'client.browser' )
assert( require 'client.game' )
scenes.load( 'menu' )
end

View File