summaryrefslogtreecommitdiff
path: root/client/main.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-01-29 02:59:50 +0000
committerubq323 <ubq323@ubq323.website>2023-01-29 02:59:50 +0000
commitebe12a65c07bccfbc704667c88d8125be33067cf (patch)
tree9c1ef457ce0da96b4d5dbe77cd56625f53b4ba89 /client/main.lua
parent9b659149c7273a57a82c9be988a8a78c62bb23f4 (diff)
camera stuff + vastly optimise hex drawing
Diffstat (limited to 'client/main.lua')
-rw-r--r--client/main.lua34
1 files changed, 30 insertions, 4 deletions
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