title: How to draw objects that can be dragged and droped on the screen using pygame?
body: <p>I am trying to draw 5 rectangles all of which I can drag and drop across the screen. I am using pygame. I managed to draw 1 rectangle that I can drag and drop but I can't do it with 5. This is my code:</p>
  
  <pre><code>import pygame
  from pygame.locals import *
  from random import randint
  
  
  SCREEN_WIDTH = 1024
  SCREEN_HEIGHT = 768
  
  BLACK = (  0,   0,   0)
  WHITE = (255, 255, 255)
  RED   = (255,   0,   0)
  pygame.init()
  
  screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
  screen_rect = screen.get_rect()
  
  pygame.display.set_caption("Moving circles")
  
  rectangle = pygame.rect.Rect(20,20, 17, 17)
  rectangle_draging = False
  
  
  clock = pygame.time.Clock()
  
  running = True
  
  while running:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              running = False
  
          elif event.type == pygame.MOUSEBUTTONDOWN:
              if event.button == 1:            
                  if rectangle.collidepoint(event.pos):
                      rectangle_draging = True
                      mouse_x, mouse_y = event.pos
                      offset_x = rectangle.x - mouse_x
                      offset_y = rectangle.y - mouse_y
  
          elif event.type == pygame.MOUSEBUTTONUP:
              if event.button == 1:            
                  rectangle_draging = False
  
          elif event.type == pygame.MOUSEMOTION:
              if rectangle_draging:
                  mouse_x, mouse_y = event.pos
                  rectangle.x = mouse_x + offset_x
                  rectangle.y = mouse_y + offset_y
  
  
      screen.fill(WHITE)
      pygame.draw.rect(screen, RED, rectangle)
  
      pygame.display.flip()
  
  clock.tick(FPS)
  
  
  pygame.quit()
  </code></pre>
  
  <p>I guess this is the most important part: </p>
  
  <pre><code>  pygame.draw.rect(screen, RED, rectangle)
  </code></pre>
  
  <p>Every time I try drawing 5 of them I can't drag any of them. Does anyone have a solution for this?</p>