diff options
Diffstat (limited to 'client/main.lua')
-rw-r--r-- | client/main.lua | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/client/main.lua b/client/main.lua index 2fad49e..7af1bd4 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,7 +10,7 @@ local local_player = nil local drawing = require"drawing" local coords = require"common.coords" local Pos = coords.Pos -local camera = require"camera".Camera.make() +local camera = require"camera".Camera:make() local Chunk = require"common.chunk".Chunk local util = require"util" @@ -24,10 +24,10 @@ local host,peer local chunk -local f3mode = false +_G.debugmode = false function love.keypressed(key,scancode,isrepeat) - if scancode == "f3" then f3mode = not f3mode end + if scancode == "f3" then _G.debugmode = not _G.debugmode end end local function draw_player(pl,islocal) @@ -45,7 +45,8 @@ end local remote_players = {} local function update_local_player(pl,dt) - local SPEED = 10 -- pixels/sec + local SPEED = 10 -- units/sec + if love.keyboard.isScancodeDown("lshift") then SPEED = 100 end local function kd(code) if love.keyboard.isScancodeDown(code) then return 1 else return 0 end end @@ -85,10 +86,11 @@ function love.update(dt) update_local_player(local_player,dt) if love.keyboard.isScancodeDown"q" then camera.zoom = camera.zoom*1.05 end if love.keyboard.isScancodeDown"e" then camera.zoom = camera.zoom/1.05 end + camera.zoom = math.max(2.25,math.min(50,camera.zoom)) sync_local_player(local_player,peer) end if chunk then - local mh = camera:screen_to_world(Pos.make(love.mouse.getPosition())):to_hex():round() + local mh = camera:screen_to_world(Pos:make(love.mouse.getPosition())):to_hex():round() if false== chunk:at(mh) and love.mouse.isDown(1) then chunk:set_at(mh,true) -- print(mh,true) @@ -108,7 +110,7 @@ function love.update(dt) local op = j.t if op == "join" then local pl = j.pl - remote_players[pl.id] = {pos=coords.Pos.make(pl.x,pl.y),color=pl.color,id=pl.id} + remote_players[pl.id] = {pos=coords.Pos:make(pl.x,pl.y),color=pl.color,id=pl.id} elseif op == "leave" then local id = j.id remote_players[id]=nil @@ -119,11 +121,11 @@ function love.update(dt) remote_players[id].pos.y = y elseif op == "you" then local pl = j.pl - local_player = {pos=coords.Pos.make(pl.x,pl.y),color=pl.color,id=pl.id} + 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) elseif op == "settile" then - local h = coords.Hex.make(j.q,j.r) + local h = coords.Hex:make(j.q,j.r) chunk:set_at(h,j.tile) end end @@ -152,12 +154,12 @@ function love.draw() love.graphics.setColor(1,0,0) love.graphics.rectangle("fill",0,0,1,1) - local sm = Pos.make(love.mouse.getPosition()) + local sm = Pos:make(love.mouse.getPosition()) local wm = camera:screen_to_world(sm) local hm = wm:to_hex() love.graphics.origin() - if f3mode and local_player then + if _G.debugmode and local_player then util.print_good({ "ms "..tostring(sm), "mw "..tostring(wm), |