title: Collision Detection between two images in Java
body: <p>I have two characters displayed in a game I am writing, the player and the enemy. defined as such:</p>
  
  <pre><code>public void player(Graphics g) {
      g.drawImage(plimg, x, y, this);
  }
  
  public void enemy(Graphics g) {
      g.drawImage(enemy, 200, 200, this);
  }
  </code></pre>
  
  <p>Then called with:</p>
  
  <pre><code>player(g);
  enemy(g);
  </code></pre>
  
  <p>I am able to move player() around with the keyboard, but I am at a loss when trying to detect a collision between the two. A lot of people have said to use Rectangles, but being a beginner I cannot see how I would link this into my existing code. Can anyone offer some advice for me?</p>