title: How do I make something happen when the mouse cursor hovers over an image
body: <p>Ok so I am working on a home screen for my game and I have an image that acts as a button.
  So when you click some where on the image the image changes then imports the next part of the game. But what I want to do as well is when the mouse hovers over the image it will play a sound. But how do I get it to detect when the mouse is being hovered over the button image?</p>
  
  <p>Here is a copy of my code for the home screen. ps. I figured out my problem now you can seem my code here.(This is all the code so far for my home screen. Any was thanks to any one who can help me make it detect when the mouse in hovering over the image.)</p>
  
  <pre><code>import pygame, sys, random
  import time
  
  B_images = ["startbutton.png", "startbuttonpush.png"]
  
  class BClass(pygame.sprite.Sprite):
      def __init__(self):
          pygame.sprite.Sprite.__init__(self)
          self.image = pygame.image.load("startbutton.png")
          self.rect = self.image.get_rect()
          self.rect.center = [310, 500]
  
  
  
  
  def animate():
      screen.fill([0,0,0])
      screen.blit(B.image,B.rect)
      pygame.display.flip()
  
  
  
  pygame.init()
  x = y = 0
  pos = pygame.mouse.get_pos()
  pygame.display.set_caption("Skier")
  screen = pygame.display.set_mode([640,640])
  B = BClass()
  font = pygame.font.Font(None, 50)
  ButtonSound = pygame.mixer.Sound('ButtonSound.ogg')
  
  while True:
      animate()
      for event in pygame.event.get():
          if event.type == pygame.KEYDOWN:
              if event.key == pygame.K_ESCAPE:
                  import End.py
          if event.type == pygame.MOUSEBUTTONDOWN:
              x, y = event.pos
              if ( x in range(229,391)) and (y in range(470,530)):
                  B.image = pygame.image.load("startbuttonpush.png")
                  animate()
                  time.sleep(0.1)
                  import skier.py
  </code></pre>