summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-08-26 06:23:34 +0100
committerubq323 <ubq323@ubq323.website>2023-08-26 06:23:34 +0100
commit3102095c9ff4939dfc0438339c7208ee7b2e2957 (patch)
tree36efe5d63372136fbc6af791d0dba91f05f2eb34
parentabc57f1c5a4fcf90acc650989f3dbf52b7609e9a (diff)
print usernames better, and respond to remote players usernames
-rw-r--r--client/game.lua13
-rw-r--r--server/server.lua2
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