From 242a0b4e7deb356a0015fbf536158962ad2ea29c Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 25 Feb 2023 15:09:58 +0000 Subject: move player size to constants.lua; fix channel-related bug where player movement wasn't being recieved properly --- client/main.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'client/main.lua') diff --git a/client/main.lua b/client/main.lua index e37e18f..74a8be9 100644 --- a/client/main.lua +++ b/client/main.lua @@ -5,8 +5,8 @@ local utf8 = require"utf8" local SERVER_HOSTNAME = "ubq323.website" if os.getenv"HEXEMU_LOCAL" then SERVER_HOSTNAME = "localhost" end -local PLAYER_SIZE = 0.7 +local PLAYER_SIZE = require"common.constants".PLAYER_SIZE local local_player = nil local drawing = require"drawing" @@ -96,16 +96,13 @@ function love.textinput(text) end local function draw_player(pl,islocal) - local hplsz = PLAYER_SIZE/2 love.graphics.setColor(pl.color) - love.graphics.circle("fill",pl.pos.x,pl.pos.y, hplsz) - -- love.graphics.rectangle("fill",pl.pos.x-hplsz,pl.pos.y-hplsz,PLAYER_SIZE,PLAYER_SIZE) - -- love.graphics.print(tostring(pl.id),pl.pos.x,pl.pos.y) + love.graphics.circle("fill",pl.pos.x,pl.pos.y, PLAYER_SIZE) + if islocal then love.graphics.setLineWidth(0.01) love.graphics.setColor(0.5,0,0) - love.graphics.circle("line",pl.pos.x,pl.pos.y,hplsz) - -- love.graphics.rectangle("line",pl.pos.x-hplsz,pl.pos.y-hplsz,PLAYER_SIZE,PLAYER_SIZE) + love.graphics.circle("line",pl.pos.x,pl.pos.y,PLAYER_SIZE) end end @@ -210,6 +207,7 @@ function love.update(dt) -- print(ev.data) local j = json.decode(ev.data) local op = j.t + -- if op ~= "chunk" then print(ev.channel,ev.data) end if op == "join" then local pl = j.pl remote_players[pl.id] = {pos=coords.Pos:make(pl.x,pl.y),color=pl.color,id=pl.id} @@ -314,7 +312,7 @@ function love.load() love.keyboard.setKeyRepeat(true) -- require"profile".start(10,io.open("./trace","w")) host = enet.host_create() - peer = host:connect(SERVER_HOSTNAME..":8473") + peer = host:connect(SERVER_HOSTNAME..":8473",2) msgbox.add("connected to "..SERVER_HOSTNAME..":8473") msgbox.add("press F1 for controls help") end -- cgit v1.2.3