title: Collision between player and enemy not working
body: <p>I am making a game in Java. And the collision between player and enemy is not working right.</p>
  
  <p>What I want: when they collide, it's Game Over and we need to go to the Game Over Panel. 
  What it does instead: the enemy runs over the player and the game just goes on. </p>
  
  <p>I copy pasted a piece of my code and I really hope someone can find what I am doing wrong. </p>
  
  <p>For further information, the player and enemies can should bullets to each other and that collision works. There are also obstacles placed randomly, which both player and enemy detect.</p>
  
  <p>What do to when player collides with an enemy:</p>
  
  <pre><code>for(Enemy enemy: enemies){
  if (checkCollision(player, enemy)){
      player.dead = true;
      }
  }
  </code></pre>
  
  <p>I update the player in the action performed function:</p>
  
  <pre><code>if (!player.dead)
              player.redraw();
  
  else
  {
      spelTimer.stop();
      mainVenster.switchPanel(new GameOverPanel(mainVenster));}
  </code></pre>
  
  <p>Function checkCollision (idk if this can be helpful):</p>
  
  <pre><code>public boolean checkCollision(tanks.Game_Object object1, tanks.Game_Object object2){
  
      double dx = object1.x_pos - object2.x_pos;
      double dy = object1.y_pos - object2.y_pos;
      double distance = (dx*dx) + (dy*dy);
      double minDistance = (object1.r+object2.r);
  
      return (distance &lt; minDistance*minDistance);    
  }
  </code></pre>
  
  <p>EDIT: The x_pos and y_pos are the center coordinates of my objects and r is the radius.</p>