I'm making my first game in, Pong, and I'm trying to make the ball's Y increase or decrease, depending on where it impacts the paddle. After implementing the code below, the ball only goes down, but not up. What could the problem be?
if(paddle.detectCollison(ball)){
//30px on either side of the actual center of the paddle is considered the center
if((ball.getY() > ((paddle.getH() / 2) + 30)))
ball.setY(ball.getY() + 10);
else if ((ball.getY() < ((paddle.getH() /2) - 30)))
ball.setY(ball.getY() - 10);
ball.setDX(-(ball.getDX()));
}
if (...) { ... }– ashes999 Feb 20 '12 at 17:30