title: How do I check to see if a mouse click is within a circle in pygame?
body: <pre><code>import pygame
  
  pygame.init()
  
  white = 255,255,255
  cyan = 0,255,255
  
  gameDisplay = pygame.display.set_mode((800,600))
  pygame.display.set_caption('Circle Click Test')
  
  stop = False
  
  while not stop:
      gameDisplay.fill(white)
  
      pygame.draw.circle(gameDisplay,cyan,(400,300),(100))
  
      for event in pygame.event.get():
  
          if event.type == pygame.MOUSEBUTTONDOWN:
              ####################################################  
  
          if event.type == pygame.QUIT:
              pygame.quit()
              sys.exit()
  
      pygame.display.update()
  </code></pre>
  
  <p>Here I have a circle on the screen, and I would like to check to see if the user
  clicked within the circle. I know how to do this with a rectangle, I would assume it would be similar. Thanks for any help, I am quite new to pygame.</p>
  
  <p>here is what I have for rectangles:</p>
  
  <pre><code>import pygame
  
  pygame.init()
  
  white = 255,255,255
  cyan = 0,255,255
  
  gameDisplay = pygame.display.set_mode((800,600))
  pygame.display.set_caption('Circle Click Test')
  
  rectangle = pygame.Rect(400,300,200,200)
  
  stop = False
  
  while not stop:
      gameDisplay.fill(white)
  
      pygame.draw.rect(gameDisplay, cyan,rectangle,4)
  
      for event in pygame.event.get():
  
          if event.type == pygame.MOUSEBUTTONDOWN:
              click = rectangle.collidepoint(pygame.mouse.get_pos())
  
              if click == 1:
                  print 'CLICKED!'
  
          if event.type == pygame.QUIT:
              pygame.quit()
              sys.exit()
  
      pygame.display.update()
  </code></pre>