diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/drawing.lua | 2 | ||||
-rw-r--r-- | client/main.lua | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/client/drawing.lua b/client/drawing.lua index c8be5fd..962fdb7 100644 --- a/client/drawing.lua +++ b/client/drawing.lua @@ -55,7 +55,7 @@ local function draw_chunk(camera,the_chunk) local maxq = minq+(trh.q-tlh.q)+1 for q = minq,maxq do local h = coords.Hex.make(q,r) - local t = the_chunk:tile_at_offset(h) + local t = the_chunk:at(h) if t then draw_hex(h:to_pos()) end 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) |