title: Simple Collision Detection - Android
body: <p>I want to do really simple collision detection in a pong like game.
  The ball is a square and the paddle (bats) is rectangles.</p>
  
  <p>I have two entities coming in where I can get the current X and Y position, and the bitmap height and width. Which is the simplest way to do this?</p>
  
  <p>I have this code:</p>
  
  <pre><code>public void getCollision(Entity enitityOne, Entity enitityTwo){
  
      double eventCoordX = (enitityOne.getCenterX() - (enitityTwo.getBitmapWidth() / 2));
      double eventCoordY = (enitityOne.getCenterY() - (enitityTwo.getBitmapHeight() / 2));
  
      double X = Math.abs(enitityTwo.getxPos() - eventCoordX);
      double Y = Math.abs(enitityTwo.getyPos() - eventCoordY);
  
      if(X &lt;= (enitityTwo.getBitmapWidth()) &amp;&amp; Y &lt;= (enitityTwo.getBitmapHeight())){
          enitityOne.collision();
          enitityTwo.collision();
      }
  }
  </code></pre>
  
  <p>But I'm pretty blind, this only works in the middle of the paddle not on the sides.
  The problem is I can't see where the code is wrong.
  Anybody?
  Anybody have a better idea?</p>