title: How to make an enemy follow the player in pygame?
body: <p>I made part of a game. It runs well but I would like to add enemies in my game. So far I add the image of the enemies in pygame sprites.<br />
  But how do I make the enemies follow the player? I tried do this but it just made the image of the enemy direct to the player:</p>
  <pre class="lang-py prettyprint-override"><code>def moveEnemy(self):
      enemies.rect.x = player.rect.x
      enemies.rect.y = player.rect.y
      all_sprites_list.add(enemies)
      enemies_list.add(enemies)
  </code></pre>
  <p>I thought this would make the image of the enemy follow the player. Instead it just overlaped the player's image.</p>
  <p>I read though many pygame sprites examples but the examples saids to replace the <code>enemies.rect.x = player.rect.x</code> with <code>enemies.rect.x = -5</code> or something around that. I also tried this but it just move the image up instead of following the player.</p>
  <p>Do I have to formulate an equation? If so I do not know how to.<br />
  How do I make the enemy move but as well make it follow the player? Can someone help me solve this problem?</p>
  <p>Any help would be appreciated.</p>