@@ -25,11 +25,20 @@ function eball:collides(paddle) | |||||
return true | return true | ||||
end | end | ||||
end | end | ||||
function eball:reset(ballnum) | |||||
function eball:reset(ballnum, player) | |||||
if (gameMode == 'practice') then | if (gameMode == 'practice') then | ||||
if (self.x < 1) then | if (self.x < 1) then | ||||
--love.window.setTitle(self.x) | --love.window.setTitle(self.x) | ||||
self.x = VIRTUAL_WIDTH /2 - 2 | |||||
if not player then | |||||
self.x = VIRTUAL_WIDTH /2 - 2 | |||||
elseif player == 1 then | |||||
self.x = 50 | |||||
elseif player == 2 then | |||||
self.x = VIRTUAL_WIDTH - 50 | |||||
else | |||||
self.x = VIRTUAL_WIDTH /2 - 2 | |||||
end | |||||
self.y = VIRTUAL_HEIGHT /2 - 2 | self.y = VIRTUAL_HEIGHT /2 - 2 | ||||
self.dy = math.random(-1, 1) | self.dy = math.random(-1, 1) | ||||
self.dx = math.random(-1,1) | self.dx = math.random(-1,1) | ||||
@@ -808,7 +808,7 @@ function nettest(dt) | |||||
end | end | ||||
if (ball[1].x > VIRTUAL_WIDTH/2) and gameState ~= "play" then | |||||
if (ball[1].x > VIRTUAL_WIDTH/2) then | |||||
die = tonumber(p[2]) | die = tonumber(p[2]) | ||||
lastSentKeyClient, | lastSentKeyClient, | ||||
ball[1].dy, | ball[1].dy, | ||||
@@ -893,7 +893,7 @@ function clienttest(dt) | |||||
end | end | ||||
for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
local die = tonumber(p[2]) | local die = tonumber(p[2]) | ||||
if (ball[i].x <= VIRTUAL_WIDTH/2) or gameState ~= "play" then | |||||
if (ball[i].x <= VIRTUAL_WIDTH/2) then | |||||
lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED = 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]), tonumber(p[14]) | lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED = 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]), tonumber(p[14]) | ||||
else | else | ||||
lastSentKeyClient = p[1] | lastSentKeyClient = p[1] | ||||
@@ -1476,7 +1476,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE | |||||
TEXT = "Lets Begin!" | TEXT = "Lets Begin!" | ||||
ball_DIR = 1 | ball_DIR = 1 | ||||
for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
ball[i]:reset(i) | |||||
ball[i]:reset(i, 1) | |||||
end | end | ||||
gameState = "play" | gameState = "play" | ||||
@@ -1488,7 +1488,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE | |||||
TEXT = "" | TEXT = "" | ||||
ball_DIR = -1 | ball_DIR = -1 | ||||
for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
ball[i]:reset(i) | |||||
ball[i]:reset(i, 2) | |||||
end | end | ||||
gameState = "play" | gameState = "play" | ||||
@@ -1498,7 +1498,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE | |||||
TEXT = "Lets Begin" | TEXT = "Lets Begin" | ||||
ball_DIR = -1 | ball_DIR = -1 | ||||
for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
ball[i]:reset(i) | |||||
ball[i]:reset(i, 2) | |||||
end | end | ||||
--love.window.setTitle("An atttttttt") | --love.window.setTitle("An atttttttt") | ||||
gameState = "play" | gameState = "play" | ||||
@@ -404,7 +404,7 @@ function goalManager() | |||||
if globalState ~= "clienttest" or (globalState == "clienttest" and gameState == "1serve") then | if globalState ~= "clienttest" or (globalState == "clienttest" and gameState == "1serve") then | ||||
gameState = "1serve" | gameState = "1serve" | ||||
serveBot() | serveBot() | ||||
ball[i]:reset(i) | |||||
ball[i]:reset(i, 1) | |||||
end | end | ||||
end | end | ||||
end | end | ||||
@@ -446,7 +446,7 @@ function goalManager() | |||||
gameState = "2serve" | gameState = "2serve" | ||||
serveBot() | serveBot() | ||||
ball[i]:reset(i) | |||||
ball[i]:reset(i, 2) | |||||
end | end | ||||