From ebe12a65c07bccfbc704667c88d8125be33067cf Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sun, 29 Jan 2023 02:59:50 +0000 Subject: camera stuff + vastly optimise hex drawing --- client/main.lua | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'client/main.lua') diff --git a/client/main.lua b/client/main.lua index fe2bf06..14392d1 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,14 +1,15 @@ local enet = require"enet" local words = require"common.words" -local SERVER_HOSTNAME = "ubq323.website" --- local SERVER_HOSTNAME = "localhost" +-- local SERVER_HOSTNAME = "ubq323.website" +local SERVER_HOSTNAME = "localhost" local PLAYER_SIZE = 0.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 pprint=require"common.pprint" @@ -122,7 +123,7 @@ function love.draw() end camera:apply_trans() - drawing.draw_chunk(chunk) + drawing.draw_chunk(camera,chunk) if local_player then draw_player(local_player,true) @@ -131,15 +132,40 @@ function love.draw() draw_player(pl) end + love.graphics.setColor(1,0,0) + love.graphics.rectangle("fill",0,0,1,1) + + local sm = Pos.make(love.mouse.getPosition()) + local wm = camera:screen_to_world(sm) + local hm = wm:to_hex():round() + + local tl,br = camera:extents() + + love.graphics.origin() + love.graphics.scale(2) + love.graphics.setColor(1,1,1) + love.graphics.print(table.concat( + {"sm "..tostring(sm), + "wm "..tostring(wm), + "hm "..tostring(hm), + "", + "tl "..tostring(tl), + "br "..tostring(br)}, + "\n"),10,10) + + + + 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() peer:disconnect() host:flush() end -- cgit v1.2.3