Pong help
Posted: Thu Oct 24, 2013 7:08 am
Ok so what i'm trying to do here, is get it so that when someone scores the ball will be stuck to the paddle and move with it until enter is pressed.
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
The code that's supposed to move the ball with the paddle starts at line 8. I'm obviously doing something wrong somewhere. Can someone help me out?
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
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