diff options
author | ubq323 <ubq323@ubq323.website> | 2023-02-25 15:09:58 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-02-25 15:09:58 +0000 |
commit | 242a0b4e7deb356a0015fbf536158962ad2ea29c (patch) | |
tree | 534e6e975ba08d013c1a518729775ccde5eee7d0 /client | |
parent | 41a7a40ecf71613c6cb3f7823491c45d9c9c63e0 (diff) |
move player size to constants.lua; fix channel-related bug where player movement wasn't being recieved properly
Diffstat (limited to 'client')
-rw-r--r-- | client/main.lua | 14 | ||||
-rw-r--r-- | client/movement.lua | 2 |
2 files changed, 7 insertions, 9 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 diff --git a/client/movement.lua b/client/movement.lua index 3c9f104..33e0532 100644 --- a/client/movement.lua +++ b/client/movement.lua @@ -64,7 +64,7 @@ local function hex_sdgf(pos, hex) return hex_sdgf_00(pos-hex:to_pos()) end -local PLAYER_SIZE = 0.35 +local PLAYER_SIZE = require"common.constants".PLAYER_SIZE local function collide_with_terrain(old_pos, try_pos, map, tries_remaining) tries_remaining = tries_remaining or 3 if tries_remaining <= 0 then return old_pos end |