Selaa lähdekoodia

fix??

tags/online
madiwka3 4 vuotta sitten
vanhempi
commit
bb7b784031
2 muutettua tiedostoa jossa 20 lisäystä ja 7 poistoa
  1. +19
    -6
      main.lua
  2. +1
    -1
      src/baseGame.lua

+ 19
- 6
main.lua Näytä tiedosto

@@ -744,7 +744,7 @@ function love.update(dt)
if ts > updaterate then
clienttest(dt)
ts = ts - updaterate
end
end
end

@@ -783,14 +783,20 @@ function nettest(dt)
"|HOST")
print("SENT: " .. lastSentKey)
end
data = udp:receive()

local data
local datanumtest = 0
repeat
datanumtest = datanumtest + 1
print("LATENCY: " .. tostring(datanumtest))
data = udp:receive()
if data then
confirmation = "N"
local p = split(data, '|')
if p[3] ~= "CLIENT" then
confirmation = "U"
end
if tonumber(p[4]) > 5 then
if tonumber(p[4]) > 90 then
confirmation = "L"
end
lastSentKeyClient = p[1]
@@ -801,6 +807,7 @@ function nettest(dt)
confirmation = "D"
print("NO PLAYER 2!!")
end
until not data
end
function clienttest(dt)
if clientinit == false then
@@ -810,14 +817,20 @@ function clienttest(dt)
udp = socket.udp()
udp:setpeername(address, port)
udp:settimeout(0)
udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT")
clientinit = true
end
udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT")
print("SENT TO SERVER:" .. lastSentKey)
local data
local datanumtest = 0
repeat
datanumtest = datanumtest + 1
print("LATENCY: " .. tostring(datanumtest))
data = udp:receive()
if data then
print(data)
udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT")
print("SENT TO SERVER:" .. lastSentKey)
confirmation = "N"
local p = split(data, '|')
if p[13] then
@@ -836,7 +849,7 @@ function clienttest(dt)
confirmation = "D"
end
print("GOT: " .. lastSentKeyClient)
until not data
end
function wallbreaker(x, y)
if (gameState == "editor") then


+ 1
- 1
src/baseGame.lua Näytä tiedosto

@@ -995,7 +995,7 @@ function clientsBaseGame(dt)
print("moving player1 down")
else
player1.dy = 0
print("stopping player")
-- print("stopping player")
end
if ((love.keyboard.isDown(p2control.up))) then
player2.dy = (paddle_SPEED + p2bonus) * -1


Ladataan…
Peruuta
Tallenna