title: My game keeps calling a method for the wrong sprite
body: <p>When i try to run the game the code tries to run a method for the wrong sprite. I think the line "player.handle_keys()" is the problem as when i run it, it says that it can't find a "handle_keys()" method for the "meteor" class. I haven't got a line to run a "meteor.handle_keys()" as this class should not have this method.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import pygame
  import random
  
  # Define some colors
  BLACK = (  0,   0,   0)
  WHITE = (255, 255, 255)
  RED   = (255,   0,   0)
  
  
  bg = pygame.image.load("bg1.png")
  
  
  
  
  class space_ship(pygame.sprite.Sprite):
      def __init__(self, color, width, height):
          super().__init__()
      # Create an image of the space_ship1, and fill it with a color.
      # This could also be an image loaded from the disk.
          self.image = pygame.Surface([width, height])
          self.image.fill(WHITE)
          self.image.set_colorkey(WHITE)
          self.rect = self.image.get_rect()
      #draw image
          self.image = pygame.image.load("player1.gif").convert()
  
      # Draw the ellipse
          #pygame.draw.ellipse(self.image, color, [0, 0, width, height])
  
      # x and y coordinates
          self.x = 500
          self.y = 450
  
  
  
      def handle_keys(self):
              """ Handles Keys """
              key = pygame.key.get_pressed()
              dist = 5 # distance moved in 1 frame
              if key[pygame.K_RIGHT]: # right key
                  self.x += dist # move right
              elif key[pygame.K_LEFT]: # left key
                  self.x -= dist # move left
  
      def draw(self, surface):
          """ Draw on surface """
          # blit yourself at your current position
          surface.blit(self.image, (self.x, self.y))
  
  
  
  
  class asteroid(pygame.sprite.Sprite):
      def __init__(self, color, width, height):
          super().__init__()
      # Create an image of the space_ship1, and fill it with a color.
      # This could also be an image loaded from the disk.
          self.image = pygame.Surface([width, height])
          self.image.fill(WHITE)
          self.image.set_colorkey(WHITE)
          self.rect = self.image.get_rect()
      # Draw the ellipse
          #pygame.draw.ellipse(self.image, color, [0, 0, width, height])
  
          self.image = pygame.image.load("ast1.gif").convert()
  
      # x and y coordinates
          self.x = random.randint(50,950)
          self.y = 10
  
      def draw(self, surface):
          """ Draw on surface """
          # blit yourself at your current position
          surface.blit(self.image, (self.x, self.y))
  
      def fall(self):
          dist = 5
          self.y +=dist
          if self.y &gt; 600:
              self.x = random.randint(50,950)
              self.y = random.randint(-2000, -10)
  
  
  
      def respawn(self):
          self.y = -10
  
  
  
  
  
  
  # Initialize Pygame
  pygame.init()
  
  # Set the height and width of the screen
  screen_width = 1000
  screen_height = 600
  screen = pygame.display.set_mode([screen_width, screen_height])
  
  # This is a list of 'sprites.' Each sprite in the program is
  # added to this list.
  # The list is managed by a class called 'Group.'
  asteroid_list = pygame.sprite.Group()
  
  # This is a list of every sprite.
  # All asteroids and the player as well.
  all_sprites_list = pygame.sprite.Group()
  
  
  
  
  player = space_ship(RED, 20, 15)
  all_sprites_list.add(player)
  asteroid_1 = asteroid(BLACK, 40, 40)
  asteroid_list.add(asteroid_1)
  all_sprites_list.add(asteroid_1)
  asteroid_2 = asteroid(BLACK, 40, 40)
  asteroid_list.add(asteroid_2)
  all_sprites_list.add(asteroid_2)
  asteroid_3 = asteroid(BLACK,40, 40)
  asteroid_list.add(asteroid_3)
  all_sprites_list.add(asteroid_3)
  asteroid_4 = asteroid(BLACK,40, 40)
  asteroid_list.add(asteroid_4)
  all_sprites_list.add(asteroid_4)
  asteroid_5 = asteroid(BLACK,40, 40)
  asteroid_list.add(asteroid_5)
  all_sprites_list.add(asteroid_5)
  asteroid_6 = asteroid(BLACK,40, 40)
  asteroid_list.add(asteroid_6)
  all_sprites_list.add(asteroid_6)
  asteroid_7 = asteroid(BLACK,40, 40)
  asteroid_list.add(asteroid_7)
  all_sprites_list.add(asteroid_7)
  asteroid_8 = asteroid(BLACK,40, 40)
  asteroid_list.add(asteroid_8)
  all_sprites_list.add(asteroid_list)
  
  
  # Loop until the user clicks the close button.
  done = False
  
  # Used to manage how fast the screen updates
  clock = pygame.time.Clock()
  
  score = 0
  
  # ----------------- Main Program Loop --------------------
  while not done:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              done = True
  
      #Call upon function
      player.handle_keys()
  
      # Clear the screen
      screen.fill(WHITE)
  
      #INSIDE OF THE GAME LOOP
      screen.blit(bg, (0, 0))
  
      # See if the player space_ship1 has collided with anything.
      blocks_hit_list = pygame.sprite.spritecollide(player, asteroid_list, True)
  
      # Check the list of collisions.
      for player in blocks_hit_list:
          score +=1
          print(score)
  
      # Draw all the spites
      player.draw(screen)
      asteroid_1.draw(screen)
      asteroid_1.fall()
      asteroid_2.draw(screen)
      asteroid_2.fall()
      asteroid_3.draw(screen)
      asteroid_3.fall()
      asteroid_4.draw(screen)
      asteroid_4.fall()
      asteroid_5.draw(screen)
      asteroid_5.fall()
      asteroid_6.draw(screen)
      asteroid_6.fall()
      asteroid_7.draw(screen)
      asteroid_7.fall()
      asteroid_8.draw(screen)
      asteroid_8.fall()
  
  
      #all_sprites_list.draw(screen)
  
  # Limit to 60 frames per second
      clock.tick(60)
  
      # Go ahead and update the screen with what we've drawn.
      pygame.display.flip()
  
  pygame.quit()
  </code></pre>