I got it so the ball moves to where the paddle is, it just won't move with it, and I don't know why.
The code that should make it move with the paddle is this
Code: Select all
if ball.x + ball.radius < 0 then
ball.x = player.x + 33
ball.y = player.y + 75
ball.xv = 400
ball.xy = 400
player2.score = player2.score + 1
go = false
if love.keyboard.isDown("w") then
ball.y = (player.y + 75) - (player.speed * dt)
elseif love.keyboard.isDown("d") then
ball.y = (player.y + 75) + (player.speed * dt)
end
end
Also controls for the game are W and D for the left paddle, up arrow and down arrow for the right paddle, and return/enter to start the ball.
You can download the .love file at http://puu.sh/4Y4G2