title: Java Pong collision detection
body: <p>Hello I am trying to make a pong game with java and everything works great except collision part. I firstly used Bounds class and intersects method to solve this collision problem but this method only works for the collision case shown on the picture I drew.</p>
  
  <p><img src="https://i.stack.imgur.com/xmMQO.jpg" alt="error case"> </p>
  
  <p>So I wrote new code myself instead of using the Bounds class, and I successfully created method for side collision detection but I am again having hard time to solve collision detection for the top and bottom of the paddle. </p>
  
  <pre><code>public boolean collideRight(Ball ball){
      if(ball.getLayoutX()+ball.getRadius()&gt;=player.getLayoutX()&amp;&amp;(ball.getLayoutY()+ball.getRadius()&gt;=player.getLayoutY()&amp;&amp;ball.getLayoutY()-ball.getRadius()&lt;=player.getLayoutY()+height)){
          return true;
      }
      else{
          return false;
      }
  }
  </code></pre>
  
  <p>and This is the method I made for top and bottom collision detection.</p>
  
  <pre><code>public boolean collideRightUpSide(Ball ball){
      if((ball.getLayoutX()+ball.getRadius()&gt;=player.getLayoutX()&amp;&amp;ball.getLayoutX()-ball.getRadius()&lt;=player.getLayoutX()+width)&amp;&amp;(ball.getLayoutY()+ball.getRadius()&gt;=player.getLayoutY()&amp;&amp;ball.getLayoutY()-ball.getRadius()&lt;=player.getLayoutY()+height)){
          return true;
      }
      else{
          return false;
      }
  }
  </code></pre>
  
  <p>Can someone please help me.</p>