From 3102095c9ff4939dfc0438339c7208ee7b2e2957 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 26 Aug 2023 06:23:34 +0100 Subject: print usernames better, and respond to remote players usernames --- client/game.lua | 13 ++++++++++--- server/server.lua | 2 -- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client/game.lua b/client/game.lua index 1a6cd54..e219fef 100644 --- a/client/game.lua +++ b/client/game.lua @@ -116,7 +116,12 @@ local function draw_player(pl,islocal) end if pl.username then - util.print_good(pl.username, pl.pos.x, pl.pos.y) + -- think of a better way to unscale but keep transformation + love.graphics.push() + love.graphics.translate(pl.pos.x, pl.pos.y) + love.graphics.scale(1/camera.zoom) + util.print_good(pl.username, 0, 0) + love.graphics.pop() end end @@ -189,7 +194,8 @@ local function handle_net() local pl = j.pl remote_players[pl.id] = { pos=coords.Pos:make(pl.x,pl.y), - color=pl.color, id=pl.id + color=pl.color, id=pl.id, + username = pl.username, } msgbox.add(pl.id.." joined") elseif op == "leave" then @@ -205,7 +211,8 @@ local function handle_net() local pl = j.pl local_player = { pos=coords.Pos:make(pl.x,pl.y), - color=pl.color, id=pl.id, username=pl.username + color=pl.color, id=pl.id, + username=pl.username, } elseif op == "chunk" then local ch = ChunkC:from_packet_data(j) diff --git a/server/server.lua b/server/server.lua index a6fd42b..8a725af 100644 --- a/server/server.lua +++ b/server/server.lua @@ -19,8 +19,6 @@ print(host:get_socket_address()) -- sequential list of all players local playerlist = {} --- this is maybe suboptimal --- but it is simplest for now local function player_by_id(id) for i,pl in ipairs(playerlist) do if pl.id == id then return pl, i end -- cgit v1.2.3