Browse Source

Testing speed capabilites

tags/online
madiwka3 4 years ago
parent
commit
11f0c07b8f
2 changed files with 20 additions and 17 deletions
  1. +17
    -8
      main.lua
  2. +3
    -9
      src/baseGame.lua

+ 17
- 8
main.lua View File

@@ -24,7 +24,7 @@ wall1width = 30
nuclearanimation = 3 nuclearanimation = 3
easternum = 0 easternum = 0
ball_DIR = 0 ball_DIR = 0
updaterate = 0.05
updaterate = 0.03
RED = 255 RED = 255
hitNum = {} hitNum = {}
hitNum[1] = 0 hitNum[1] = 0
@@ -775,6 +775,7 @@ function nettest(dt)
'|' .. tostring(ball[i].y) .. '|' .. tostring(ball[i].y) ..
'|' .. gameState .. '|' .. gameState ..
'|' .. tostring(ball[i].dx) .. '|' .. tostring(ball[i].dx) ..
'|' .. tostring(ballSpeed)
"|HOST") "|HOST")
print("SENT: " .. lastSentKey) print("SENT: " .. lastSentKey)
ts = 0 ts = 0
@@ -783,12 +784,13 @@ function nettest(dt)


local data local data
local datanumtest = 0 local datanumtest = 0
local datawaspassed = false
repeat repeat
datanumtest = datanumtest + 1 datanumtest = datanumtest + 1
print("LATENCY: " .. tostring(datanumtest)) print("LATENCY: " .. tostring(datanumtest))
data = udp:receive() data = udp:receive()
if data then if data then
datawaspassed = true
print("ReceivedINFO: " .. data) print("ReceivedINFO: " .. data)
confirmation = "N" confirmation = "N"
local p = split(data, '|') local p = split(data, '|')
@@ -802,7 +804,10 @@ function nettest(dt)
player2.y = tonumber(p[2]) player2.y = tonumber(p[2])
end end
until not data
until not data
if not datawaspassed then
confirmation = "D"
end
end end
function clienttest(dt) function clienttest(dt)
if clientinit == false then if clientinit == false then
@@ -822,6 +827,7 @@ function clienttest(dt)
end end
local data local data
local datanumtest = 0 local datanumtest = 0
local datawaspassed = false
repeat repeat
datanumtest = datanumtest + 1 datanumtest = datanumtest + 1
print("LATENCY: " .. tostring(datanumtest)) print("LATENCY: " .. tostring(datanumtest))
@@ -829,25 +835,28 @@ function clienttest(dt)
if data then if data then
print("RECEIVED DATA: " .. data) print("RECEIVED DATA: " .. data)
datawaspassed = true
print("SENT TO SERVER:" .. lastSentKey) print("SENT TO SERVER:" .. lastSentKey)
confirmation = "N" confirmation = "N"
local p = split(data, '|') local p = split(data, '|')
if p[13] then
if p[13] ~= "HOST" then
if p[14] then
if p[14] ~= "HOST" then
confirmation = "U" confirmation = "U"
end end
if tonumber(p[14]) > 90 then
if tonumber(p[15]) > 90 then
confirmation = "L" confirmation = "L"
end end
for i = 1, maxBalls do for i = 1, maxBalls do
local die = tonumber(p[2]) local die = tonumber(p[2])
lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12])
lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13])
end end
end end
end end
print("GOT: " .. lastSentKeyClient) print("GOT: " .. lastSentKeyClient)
until not data until not data
if not datawaspassed then
confirmation = "D"
end
end end
function wallbreaker(x, y) function wallbreaker(x, y)
if (gameState == "editor") then if (gameState == "editor") then


+ 3
- 9
src/baseGame.lua View File

@@ -456,20 +456,20 @@ end
function powerAvailability() function powerAvailability()
if (player1nukescore >= 20 and player1nukescore < 140) then if (player1nukescore >= 20 and player1nukescore < 140) then
potentialstrike1 = 1 potentialstrike1 = 1
if (((globalState ~= "clienttest" and love.keyboard.isDown(p1control.super)) or (confirmation == "confirmed" and lastSentKeyP1 == p1control.super)) ) then
if (((globalState ~= "clienttest" and love.keyboard.isDown(p1control.super)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then
player1striken = 1 player1striken = 1
player1reverbav = 0 player1reverbav = 0
end end
end end
if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false then if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false then
player1reverbav = 1 player1reverbav = 1
if ((confirmation == "confirmed" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.counter))) then
if ((globalState == "clienttest" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.counter))) then
powerControl(1, "special") powerControl(1, "special")
end end
end end
if (player1nukescore >= 200) then if (player1nukescore >= 200) then
potentialnuke1 = 1 potentialnuke1 = 1
if ((confirmation == "confirmed" and lastSentKeyP1 == p1control.super)or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
if ((globalState == "clienttest" and lastSentKeyP1 == p1control.super)or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
sounds["nuke"]:play() sounds["nuke"]:play()
if areanuclear == 1 then if areanuclear == 1 then
maxspeed = maxspeed + 50 maxspeed = maxspeed + 50
@@ -965,12 +965,6 @@ function rules(query, i)
end end
end end
function clientsBaseGame(dt) function clientsBaseGame(dt)
if confirmation == "confirmed" then
player2.RED = 0
print("KEYS ARE: " .. confirmation .. " " .. lastSentKeyP1)
else
TEXT = "DISCONNECTED"
end
if gameMode == "reverse" then if gameMode == "reverse" then
reversegame(dt) reversegame(dt)
end end


Loading…
Cancel
Save