summaryrefslogtreecommitdiff
path: root/client/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'client/main.lua')
-rw-r--r--client/main.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/client/main.lua b/client/main.lua
index f74cfa9..e37e18f 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -13,11 +13,12 @@ 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 ChunkC = require"chunk".ChunkC
local util = require"util"
local Map = require"common.map".Map
local movement = require"movement"
local msgbox = require"msgbox"
+local drawing2 = require"drawing2"
-- local pprint=require"common.pprint"
-- pprint.setup{show_all=true}
@@ -97,12 +98,14 @@ end
local function draw_player(pl,islocal)
local hplsz = PLAYER_SIZE/2
love.graphics.setColor(pl.color)
- love.graphics.rectangle("fill",pl.pos.x-hplsz,pl.pos.y-hplsz,PLAYER_SIZE,PLAYER_SIZE)
+ love.graphics.circle("fill",pl.pos.x,pl.pos.y, hplsz)
+ -- love.graphics.rectangle("fill",pl.pos.x-hplsz,pl.pos.y-hplsz,PLAYER_SIZE,PLAYER_SIZE)
-- love.graphics.print(tostring(pl.id),pl.pos.x,pl.pos.y)
if islocal then
love.graphics.setLineWidth(0.01)
love.graphics.setColor(0.5,0,0)
- love.graphics.rectangle("line",pl.pos.x-hplsz,pl.pos.y-hplsz,PLAYER_SIZE,PLAYER_SIZE)
+ love.graphics.circle("line",pl.pos.x,pl.pos.y,hplsz)
+ -- love.graphics.rectangle("line",pl.pos.x-hplsz,pl.pos.y-hplsz,PLAYER_SIZE,PLAYER_SIZE)
end
end
@@ -111,7 +114,7 @@ local remote_players = {}
local function update_local_player(pl,dt)
local SPEED = 8*math.sqrt(3) -- 8 hexagonheights per second
- if love.keyboard.isDown("lshift") then SPEED = SPEED*2.5 end
+ if love.keyboard.isDown("lshift") then SPEED = SPEED*2 end
local function kd(code)
if love.keyboard.isScancodeDown(code) then return 1 else return 0 end
end
@@ -131,13 +134,14 @@ local function update_local_player(pl,dt)
local try_pos = Pos:make(pl.pos.x + SPEED*dt*dx, pl.pos.y + SPEED*dt*dy)
pl.pos = movement.collide_with_terrain(pl.pos,try_pos,map)
+ -- pl.pos = try_pos
pl.pos_dirty = true
end
local function sync_local_player(pl)
-- send updated info about local player to server
if pl.pos_dirty then
- peer:send(json.encode{t="ppos",x=pl.pos.x,y=pl.pos.y})
+ peer:send(json.encode{t="ppos",x=pl.pos.x,y=pl.pos.y},1)
pl.pos_dirty = false
end
end
@@ -223,7 +227,7 @@ function love.update(dt)
local pl = j.pl
local_player = {pos=coords.Pos:make(pl.x,pl.y),color=pl.color,id=pl.id}
elseif op == "chunk" then
- local ch = Chunk:from_packet_data(j)
+ local ch = ChunkC:from_packet_data(j)
map:add_chunk(ch)
elseif op == "settile" then
local h = coords.Hex:make(j.q,j.r)
@@ -244,7 +248,9 @@ function love.draw()
end
camera:apply_trans()
- drawing.draw_map(camera,map)
+ -- drawing.draw_map(camera,map)
+ drawing2.draw_map(camera,map)
+
if local_player then
draw_player(local_player,true)
@@ -301,6 +307,7 @@ function love.draw()
love.graphics.line(tw,y,tw,y+th)
end
+
end
function love.load()