@@ -449,7 +449,7 @@ private boolean testBallCollision(Paddle testingPaddle, final long nanosSinceLas
449449 if (didIntersect ) {
450450 final Side ballSide = testingPaddle .getSide ();
451451 // Determine how long it's been since the ball would've collided. time = distance / velocity
452- final double timePassedSinceCollision = ( Math .abs (ball .getX (ballSide ) - paddlePoint )) / ( ball .getRunPerNanoSecond ());
452+ final double timePassedSinceCollision = Math .abs (( ball .getX (ballSide ) - paddlePoint ) / ball .getRunPerNanoSecond ());
453453 // Determine where the paddle would have been at that time. distance = velocity * time.
454454 final double paddleTopAtTime = testingPaddle .getY (Side .TOP ) - timePassedSinceCollision * testingPaddle .getVelYNanos ();
455455 // Also get the bottom position here.
@@ -459,16 +459,8 @@ private boolean testBallCollision(Paddle testingPaddle, final long nanosSinceLas
459459 // Determine the ball's height at that time.
460460 final double ballTopYAtTime = ball .getY (Side .TOP ) - timePassedSinceCollision * (ball .getRisePerNanoSecond ());
461461 final double ballCenterAtTime = PongBall .getY (ball .getRadius (), ballTopYAtTime , Side .CENTER );
462- double goodBallPos ;
463- if (ballCenterAtTime >= paddleTopCollisionPoint ) {
464- goodBallPos = ballTopYAtTime ;
465- } else if (ballCenterAtTime <= paddleBottomCollisionPoint ) {
466- goodBallPos = PongBall .getY (ball .getRadius (), ballTopYAtTime , Side .BOTTOM );
467- } else {
468- goodBallPos = ballCenterAtTime ;
469- }
470462
471- didIntersect = doesBallIntersect (goodBallPos , paddleTopCollisionPoint , paddleBottomCollisionPoint );
463+ didIntersect = doesBallIntersect (ballCenterAtTime , paddleTopCollisionPoint , paddleBottomCollisionPoint );
472464
473465 // If there was an intersection, we need to continue even more with determining the ball's new location.
474466 if (didIntersect ) {
0 commit comments