summaryrefslogtreecommitdiff
path: root/client/main.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-02-25 15:09:58 +0000
committerubq323 <ubq323@ubq323.website>2023-02-25 15:09:58 +0000
commit242a0b4e7deb356a0015fbf536158962ad2ea29c (patch)
tree534e6e975ba08d013c1a518729775ccde5eee7d0 /client/main.lua
parent41a7a40ecf71613c6cb3f7823491c45d9c9c63e0 (diff)
move player size to constants.lua; fix channel-related bug where player movement wasn't being recieved properly
Diffstat (limited to 'client/main.lua')
-rw-r--r--client/main.lua14
1 files changed, 6 insertions, 8 deletions
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