From 5ae5cb0d1bb4b576b3d2ab7936157270d73891a7 Mon Sep 17 00:00:00 2001 From: madiwka3 Date: Tue, 18 Aug 2020 14:39:05 +0600 Subject: [PATCH] FINAL FIX PLEASE PLEASE PLEASE --- main.lua | 9 +++++---- src/baseGame.lua | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/main.lua b/main.lua index b2c7416..c1d63dd 100644 --- a/main.lua +++ b/main.lua @@ -792,13 +792,14 @@ function nettest(dt) print("ReceivedINFO: " .. data) confirmation = "N" local p = split(data, '|') - if p[2] ~= "CLIENT" then + if p[3] ~= "CLIENT" then confirmation = "U" end - if tonumber(p[3]) > 90 then + if tonumber(p[4]) > 90 then confirmation = "L" end lastSentKeyClient = p[1] + player2.y = tonumber(p[2]) end until not data @@ -811,12 +812,12 @@ function clienttest(dt) udp = socket.udp() udp:setpeername(address, port) udp:settimeout(0) - udp:send(tostring(lastSentKey) .. "|CLIENT") + udp:send(tostring(lastSentKey) ..'|' .. player2.y .. "|CLIENT") clientinit = true end ts = ts + dt if ts > updaterate then - udp:send(tostring(lastSentKey) .. "|CLIENT") + udp:send(tostring(lastSentKey) ..'|' .. player2.y .. "|CLIENT") ts = 0 end local data diff --git a/src/baseGame.lua b/src/baseGame.lua index 4007819..f4b6317 100644 --- a/src/baseGame.lua +++ b/src/baseGame.lua @@ -28,11 +28,11 @@ function basegame(dt) player1.dy = 0 end 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 - 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 - else + elseif (globalState ~= "nettest") player2.dy = 0 end end