|
I am making a breakout game. When I set my code to have the ball collide with the paddle, it always bounces off where the paddle is vertically, all across the screen. It only looks at the y value, not the x value but I have tried nested if for the x value and a & for the x value in my if statement. Here is my code so far.
//if the ball collides with the paddle
if ((ball.getY()+ball.getRad()) > paddle.getY())
{
if ((ball.getX()-ball.getRad()) > paddle.getX())
{
let vert = false;
}
}
return;
Please let me know what I am doing wrong. Thank you.
P.S. vert=false means the ball goes up
|