diff options
| -rw-r--r-- | client/main.lua | 14 | ||||
| -rw-r--r-- | client/movement.lua | 2 | ||||
| -rw-r--r-- | common/constants.lua | 2 | ||||
| -rw-r--r-- | server/server.lua | 3 | 
4 files changed, 11 insertions, 10 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 diff --git a/common/constants.lua b/common/constants.lua index bf1bb7a..af54a24 100644 --- a/common/constants.lua +++ b/common/constants.lua @@ -1,4 +1,6 @@  -- to avoid some circular dependencies  return {  	CHUNK_SIZE=64, +	-- radius +	PLAYER_SIZE=0.35,  } diff --git a/server/server.lua b/server/server.lua index 03a5fd9..097bc99 100644 --- a/server/server.lua +++ b/server/server.lua @@ -9,7 +9,7 @@ local MapS = require"map".MapS  local posix_time = require"posix.time"  math.randomseed(os.time()) -local host = enet.host_create("*:8473") +local host = enet.host_create("*:8473",nil,2)  print(host:get_socket_address())  -- sequential list of all players @@ -96,6 +96,7 @@ local function handle_ev(ev)  		local player = player_by_peer(ev.peer)  		if not player then error("sneezey "..ev.peer) end  		local j = json.decode(ev.data) +		-- print(ev.channel,ev.data)  		local op = j.t  		if op == "ppos" then  			local x,y = j.x,j.y  | 
