title: How to convert a PNG image to boundries (for circle) [pygame]?
body: <p>How can I convert a PNG file that I load in my code <em>(for <code>pygame</code>)</em> convert to boundaries for circle?</p>
  
  <p>I have the following image <em>(<code>png</code>)</em>:</p>
  
  <p><img src="https://i.stack.imgur.com/GVL3k.png" alt="Maze"></p>
  
  <p>And I am using <code>jpeg</code> file as a white background.</p>
  
  <p>I mean, how can I prevent the circle from going in the PNG image? The circle moves left, right, up, down with arrows keys.</p>
  
  <p>My code:</p>
  
  <pre><code>import pygame
  
  def main1():
      width, height = 600, 600
      posx, posy = 300, 300
      screen = pygame.display.set_mode((width, height))
      clock = pygame.time.Clock()
      velocity = (0, 0)
      done = False
      pygame.display.update()
      bg = pygame.image.load("maze1.png")
      bg1 = pygame.image.load("maze2.jpeg")
      while not done:
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  done = True
  
          keys = pygame.key.get_pressed()
          screen.blit(bg1, (0, 0))
          screen.blit(bg, (0, 0))
          if keys[pygame.K_RIGHT]:
              posx += 3
          if keys[pygame.K_UP]:
              posy -= 3
          if keys[pygame.K_LEFT]:
              posx -= 3
          if keys[pygame.K_DOWN]:
              posy += 3
          cir = pygame.draw.circle(screen, (255, 200, 240), (posx,posy), 10)
          pygame.display.flip()
          clock.tick(30)
  
  if __name__ == '__main__':
     pygame.init()
     main1()
     pygame.quit()
  </code></pre>