This is the code I have now
Code: Select all
function Ball:winOrLose()
if bounceCounter == 2 and self.x < 320 then
playerTwoScore = playerTwoScore + 1
switch = 600
Ball:respawn()
bounceCounter = 0
elseif bounceCounter == 2 and self.x > 340 then
playerOneScore = playerOneScore + 1
switch = 690
Ball:respawn()
bounceCounter = 0
end
end
What I tried to do is make 2 pairs of if statements to check if the ball is in the same position for the first bounce as in the second one. I got no errors but the ball bounced normally, and no points were gained or lost. Essentially the code didn't accomplish its task. Is there a way where I can implement this logic in a way where it can work as intended?