diff options
author | ubq323 <ubq323@ubq323.website> | 2023-02-13 16:36:09 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-02-13 16:36:09 +0000 |
commit | ef7848921174412d68e70190eb58b9ce1687ff12 (patch) | |
tree | 9a7841ef612847c9cd2a850278d297e37be78f54 /client/main.lua | |
parent | 7e0a520f8efd748a13c277b3c39514aee07c74d2 (diff) |
run length encoding for chunk data, more reasonable player speeds, controls help menu
Diffstat (limited to 'client/main.lua')
-rw-r--r-- | client/main.lua | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/client/main.lua b/client/main.lua index 244925e..6692e13 100644 --- a/client/main.lua +++ b/client/main.lua @@ -21,6 +21,14 @@ local movement = require"movement" -- pprint.setup{show_all=true} +local help_text = [[ +controls: +wasd: move left mouse: place +q,e: zoom in/out right mouse: destroy +shift: sprint +F3: toggle debug +F1: show/hide this help]] + math.randomseed(os.time()) local map = Map:make() @@ -29,8 +37,11 @@ local host,peer _G.debugmode = false +local show_controls = true + function love.keypressed(key,scancode,isrepeat) if scancode == "f3" then _G.debugmode = not _G.debugmode end + if scancode == "f1" then show_controls = not show_controls end end local function draw_player(pl,islocal) @@ -48,8 +59,9 @@ end local remote_players = {} local function update_local_player(pl,dt) - local SPEED = 10 -- units/sec - if love.keyboard.isScancodeDown("lshift") then SPEED = 100 end + local SPEED = 8*math.sqrt(3) -- 8 hexagonheights per second + + if love.keyboard.isScancodeDown("lshift") then SPEED = SPEED*2 end local function kd(code) if love.keyboard.isScancodeDown(code) then return 1 else return 0 end end @@ -183,8 +195,6 @@ function love.draw() local wm = camera:screen_to_world(sm) local hm = wm:to_hex() - sdf_d,sdf_gx,sdf_gy = movement.hex_sdgf(wm, coords.Hex:make(3,3)) - love.graphics.origin() if _G.debugmode and local_player then util.print_good({ @@ -198,24 +208,22 @@ function love.draw() "voob "..tostring(camera.zoom), "-", "fps "..tostring(love.timer.getFPS()), - "-", - "sdf "..tostring(sdf_d) },10,10) - love.graphics.setColor(0,1,0) - love.graphics.setLineWidth(5) - love.graphics.line(sm.x,sm.y, sm.x+50*sdf_gx, sm.y+50*sdf_gy) + end + if show_controls then + util.print_good(help_text,300,200) end end function love.load() - require"profile".start(10,io.open("./trace","w")) + -- require"profile".start(10,io.open("./trace","w")) host = enet.host_create() peer = host:connect(SERVER_HOSTNAME..":8473") end function love.quit() - require"profile".stop() + -- require"profile".stop() peer:disconnect() host:flush() end |