summaryrefslogtreecommitdiff
path: root/client/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'client/main.lua')
-rw-r--r--client/main.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/client/main.lua b/client/main.lua
index b2e2b3f..819753f 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -11,6 +11,7 @@ local drawing = require"drawing"
local coords = require"common.coords"
local Pos = coords.Pos
local camera = require"camera".Camera.make()
+local Chunk = require"common.chunk".Chunk
-- local pprint=require"common.pprint"
-- pprint.setup{show_all=true}
@@ -20,7 +21,7 @@ math.randomseed(os.time())
local host,peer
-local chunk = require"common.chunk".Chunk.make()
+local chunk
local function draw_player(pl,islocal)
local hplsz = PLAYER_SIZE/2
@@ -78,6 +79,7 @@ function love.update(dt)
repeat
local ev = host:service()
if ev and ev.type == "receive" then
+ print(ev.data)
local j = json.decode(ev.data)
local op = j.t
if op == "join" then
@@ -94,6 +96,8 @@ function love.update(dt)
elseif op == "you" then
local pl = j.pl
local_player = {pos=coords.Pos.make(pl.x,pl.y),color=pl.color,id=pl.id}
+ elseif op == "chunk" then
+ chunk = Chunk.from_packet_data(j)
end
end
until not ev
@@ -107,7 +111,9 @@ function love.draw()
end
camera:apply_trans()
- drawing.draw_chunk(camera,chunk)
+ if chunk then
+ drawing.draw_chunk(camera,chunk)
+ end
if local_player then
draw_player(local_player,true)