title: How create a pathfinding with pygame
body: <p>Currently in the last year of high school I want to make a video game in python with pygame. However I have a problem: how to make the monsters (sprite) go from point A to point B by following my road.
  I do not have any code to show because I do not know how to do it.</p>
  
  <p>I hope you can help me &lt;3
  <a href="https://i.stack.imgur.com/VV33L.jpg" rel="nofollow noreferrer">My map (in brown the road)</a>
  There is the try code</p>
  
  <pre><code>class Niveau_1_Monstres(pygame.sprite.Sprite):
      def __init__(self,image,position):
          super().__init__()
          self.image = pygame.image.load(image).convert_alpha()
          self.rect = self.image.get_rect()
          self.rect.topleft = position
          self.direction = 'droite' ## La direction
  
      def update(self):
          pygame.time.delay(5)#mettre 100
          #définition de la direction
          if self.rect.colliderect(lv1.rectetape1) == True:
              self.direction = 'haut'
          elif self.rect.colliderect(lv1.rectetape2) == True:
              self.direction = 'droite'   
          elif self.rect.colliderect(lv1.rectetape3) == True:
              self.direction = 'bas'     
          elif self.rect.colliderect(lv1.rectetape4) == True:
              self.direction = 'droite'      
          elif self.rect.colliderect(lv1.rectetape5) == True:
              self.direction = 'haut'    
          elif self.rect.colliderect(lv1.rectetape6) == True:
              self.direction = 'droite' 
          elif self.rect.colliderect(lv1.rectetape7) == True:
              self.direction = 'bas'
          elif self.rect.colliderect(lv1.rectetape8) == True:
              self.direction = 'gauche'   
          elif self.rect.colliderect(lv1.rectetape9) == True:
              self.direction = 'haut' 
          elif self.rect.colliderect(lv1.rectetape10) == True:
              self.direction = 'gauche'  
  
          #Mouvelent en fonction de la direction
          if self.direction == 'haut':
              self.rect.y = self.rect.y-1
          elif self.direction == 'bas':
              self.rect.y = self.rect.y+1
          elif self.direction == 'gauche':
              self.rect.x = self.rect.x-1
          elif self.direction == 'droite':
              self.rect.x = self.rect.x+1   
  </code></pre>