diff --git a/src/break_out/model/Ball.java b/src/break_out/model/Ball.java index f674bbd..94d3d46 100644 --- a/src/break_out/model/Ball.java +++ b/src/break_out/model/Ball.java @@ -105,14 +105,17 @@ public class Ball implements IBall { Position posBall = this.getPosition(); // test balls y position against paddles y values + // paddles y values can be interpreted as a closed interval therefore if balls y position is in the interval, its true boolean testPaddleY = ( - (posBall.getY() <= posPaddle.getY()+paddle.getHeight() && posBall.getY() >= posPaddle.getY()) - || (posBall.getY()+Constants.BALL_DIAMETER >= posPaddle.getY() && posBall.getY() <= posPaddle.getY()+paddle.getHeight()) + posPaddle.getY() <= posBall.getY() && posBall.getY() <= posPaddle.getY()+paddle.getHeight() || + posPaddle.getY() <= posBall.getY()+Constants.BALL_DIAMETER && posBall.getY()+Constants.BALL_DIAMETER <= posPaddle.getY()+paddle.getHeight() ); // test balls x position against paddles x values + // paddles x values can be interpreted as a closed interval therefore if balls x position is in the interval, its true boolean testPaddleX = ( - posBall.getX() >= posPaddle.getX() && posBall.getX() <= posPaddle.getX()+paddle.getWidth() + posPaddle.getX() <= posBall.getX() && posBall.getX() <= posPaddle.getX()+paddle.getWidth() || + posPaddle.getX() <= posBall.getX()+Constants.BALL_DIAMETER && posBall.getX()+Constants.BALL_DIAMETER <= posPaddle.getX()+paddle.getWidth() ); // if balls y position is in paddles y values, verify x position