Browse Source

FINAL FIX PLEASE PLEASE PLEASE

tags/online
madiwka3 4 years ago
parent
commit
5ae5cb0d1b
2 changed files with 8 additions and 7 deletions
  1. +5
    -4
      main.lua
  2. +3
    -3
      src/baseGame.lua

+ 5
- 4
main.lua View File

@@ -792,13 +792,14 @@ function nettest(dt)
print("ReceivedINFO: " .. data) print("ReceivedINFO: " .. data)
confirmation = "N" confirmation = "N"
local p = split(data, '|') local p = split(data, '|')
if p[2] ~= "CLIENT" then
if p[3] ~= "CLIENT" then
confirmation = "U" confirmation = "U"
end end
if tonumber(p[3]) > 90 then
if tonumber(p[4]) > 90 then
confirmation = "L" confirmation = "L"
end end
lastSentKeyClient = p[1] lastSentKeyClient = p[1]
player2.y = tonumber(p[2])
end end
until not data until not data
@@ -811,12 +812,12 @@ function clienttest(dt)
udp = socket.udp() udp = socket.udp()
udp:setpeername(address, port) udp:setpeername(address, port)
udp:settimeout(0) udp:settimeout(0)
udp:send(tostring(lastSentKey) .. "|CLIENT")
udp:send(tostring(lastSentKey) ..'|' .. player2.y .. "|CLIENT")
clientinit = true clientinit = true
end end
ts = ts + dt ts = ts + dt
if ts > updaterate then if ts > updaterate then
udp:send(tostring(lastSentKey) .. "|CLIENT")
udp:send(tostring(lastSentKey) ..'|' .. player2.y .. "|CLIENT")
ts = 0 ts = 0
end end
local data local data


+ 3
- 3
src/baseGame.lua View File

@@ -28,11 +28,11 @@ function basegame(dt)
player1.dy = 0 player1.dy = 0
end end
if (AGAINST_AI == 0) then if (AGAINST_AI == 0) then
if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up)) or lastSentKeyClient == p2control.up) then
if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up)) ) then
player2.dy = (paddle_SPEED + p2bonus) * -1 player2.dy = (paddle_SPEED + p2bonus) * -1
elseif ((globalState ~= "nettest" and love.keyboard.isDown(p2control.down)) or lastSentKeyClient == p2control.down) then
elseif ((globalState ~= "nettest" and love.keyboard.isDown(p2control.down))) then
player2.dy = paddle_SPEED + p2bonus player2.dy = paddle_SPEED + p2bonus
else
elseif (globalState ~= "nettest")
player2.dy = 0 player2.dy = 0
end end
end end


Loading…
Cancel
Save