title: Pygame Image Collision?
body: <p>I want to make when my image (the cat) goes over the square the background will change, but it is not doing anything at the moment, could someone please help. I have a range radius but that does not seem to work. The cat is the hero. </p>
  
  <p>Is something wrong with the rectangle, should I make it into a definition instead of a variable?</p>
  
  <p>Help!</p>
  
  <pre><code>import pygame, sys
  from pygame.locals import *
  
  pygame.init()
  
  DISPLAYSURF = pygame.display.set_mode((500,500))
  pygame.display.set_caption("A Heros Journy")
  
  GREEN = (0, 255, 0)
  RED   = (255, 0, 0)
  BLUE = (0, 0, 255)
  NAVYBLUE = (0, 0, 128)
  
  hero = pygame.image.load("cat.png")
  herox = 10
  heroy = 10
  
  DISPLAYSURF.fill(GREEN)
  def main():
      global herox, hero, heroy
      mouseClicked = False
  
      boxx = 225
      boxy = 225
      DISPLAYSURF.fill(GREEN)
      DISPLAYSURF.blit(hero, (herox, heroy))
      while True:
          box = pygame.draw.rect(DISPLAYSURF, BLUE, (boxx, boxy, 50, 50))
          for event in pygame.event.get():
  
               if event.type == MOUSEMOTION:
                   herox, heroy = event.pos
                   DISPLAYSURF.fill(GREEN)
                   DISPLAYSURF.blit(hero, (herox, heroy))
  
               elif event.type == MOUSEBUTTONUP:
                   herox, heroy = event.pos
                   mouseClicked = True
  
               if hero in range(boxx, boxy):
                   DISPLAYSURF.fill(NAVYBLUE)
  
               if event.type == QUIT:
                   pygame.quit()
                   sys.exit()
          pygame.display.update()
  
  
  main()
  </code></pre>