title: How to select individual sprites for movement by clicking them?
body: <p>I am struggling to be able to move individual cars in my game. I want it so that when you click on a car and move the arrow keys, the selected car is the only one that moves. I have created a <code>Point</code> class and begun to write some code about that colliding with the cars to select them however I'm unsure what to do next. Can anyone help me to be able to select different cars by clicking on them and then be able to move that car alone.</p>
  <p>Here is my code:</p>
  <pre><code>import pygame, random, time
  
  pygame.init()
  
  class Point(pygame.sprite.Sprite):
      def __init__(self,x,y):
          super().__init__()
          self.rect=pygame.Rect(x,y,0,0)
  
  
  class Car(pygame.sprite.Sprite):
      def __init__(self,image,spawnx,spawny):
          super().__init__()
  
                  
          self.image= pygame.Surface((100,100))
          self.image = image
  
  
          self.type = &quot;car&quot;
  
          self.rect = self.image.get_rect()
          self.rect.x = spawnx
          self.rect.y = spawny
  
        
      
  
          cars.add(self)
  
      def move(self, dx, dy):
          self.rect.x += dx
          self.rect.y += dy
  
  
  
  screen = pygame.display.set_mode((1150, 650))
  background_image = pygame.image.load(&quot;carpark2.jpg&quot;)
  
  
  
  cars=pygame.sprite.Group()
  
  
  clock = pygame.time.Clock()
  
  done = False
  
  
  black=Car(pygame.image.load(&quot;blackcar.png&quot;).convert_alpha(),100,100)
  blue=Car(pygame.image.load(&quot;bluecar.png&quot;).convert_alpha(),200,100)
  yellow=Car(pygame.image.load(&quot;yellowcar.png&quot;).convert_alpha(),300,100)
  purple=Car(pygame.image.load(&quot;purplecar.png&quot;).convert_alpha(),400,100)
  orange=Car(pygame.image.load(&quot;orangecar.png&quot;).convert_alpha(),500,100)
  white=Car(pygame.image.load(&quot;whitecar.png&quot;).convert_alpha(),600,100)
  green=Car(pygame.image.load(&quot;greencar.png&quot;).convert_alpha(),700,100)
  brown=Car(pygame.image.load(&quot;browncar.png&quot;).convert_alpha(),800,100)
  pink=Car(pygame.image.load(&quot;pinkcar.png&quot;).convert_alpha(),900,100)
  
  current_car=Car(pygame.image.load(&quot;redcar.png&quot;).convert_alpha(),100,400)
  
  
  while done==False:
  
      clock.tick(30)
      
          
      for event in pygame.event.get():
  
          if event.type == pygame.MOUSEBUTTONDOWN:
              x,y = event.pos
  
              for car in pygame.sprite.spritecollide(Point(x,y,), cars, False):
                  current_car.deselect()
                  current_car = car.select()
  
                  
          if event.type == pygame.KEYDOWN:
  
              if event.key == pygame.K_LEFT:
                  current_car.move(-50,0)
              if event.key == pygame.K_RIGHT:
                  current_car.move(50,0)
                  
              if event.key == pygame.K_UP:
                  black.move(0,-50)
              if event.key == pygame.K_DOWN:
                  black.move(0,50)
  
  
  
      screen.blit(background_image, [0, 0])
      cars.draw(screen)
      
  
  
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              done = True
  
      pygame.display.flip()
  
  pygame.quit()
  </code></pre>