title: animate a click on a object python
body: <p>im having some trouble trying to animate a click on my virus object, what i want is that when someone clicks it goes down and the up again, just like someone clicked it.Im also trying to turn the object into a clickable object, changing the cursor as it passes on top of the object, however im not able to achieve this, my code is: </p>
  
  <pre><code>import pygame
  from os import path
  import random 
  
  img_dir = path.join(path.dirname(__file__), "img")
  
  width = 480
  height = 600
  fps = 30
  
  # Cores 
  white = (255, 255, 255)
  black = (0, 0, 0)
  red = (255, 0 ,0)
  green = (0, 255, 0)
  blue = (0, 0, 255)
  yellow = (255, 255, 0)
  
  # Iniciar o game
  
  pygame.init()
  pygame.mixer.init()
  screen = pygame.display.set_mode((width, height))
  pygame.display.set_caption("Trojan Clicker")
  clock = pygame.time.Clock()
  
  
  font_name = pygame.font.match_font("arial")
  def draw_text(surf, text, size, x , y):
      font = pygame.font.Font(font_name, size)
      text_surface = font.render(text, True, white)
      text_rect = text_surface.get_rect()
      text_rect.midtop = (x, y)
      surf.blit(text_surface, text_rect)
  
  
  class Player(pygame.sprite.Sprite):
      def __init__(self):
          pygame.sprite.Sprite.__init__(self)
          self.image = pygame.transform.scale(player_img, (100, 76))
          self.image.set_colorkey(black)
          self.rect = self.image.get_rect()
          self.screen_rect = screen.get_rect()
          self.rect.centerx = width / 2
          self.rect.bottom = height / 2
          self.speedy = 0
  
  
      def update(self):
          self.speedy = 0
  
  
  
  
  
  
  
  # load all game graphics
  background = pygame.image.load(path.join(img_dir, "background.png")).convert()
  background_rect = background.get_rect()
  player_img = pygame.image.load(path.join(img_dir, "first.png")).convert()
  
  
  
  all_sprites = pygame.sprite.Group()
  player = Player()
  all_sprites.add(player)
  
  
  clicks = 0
  # Loop
  running = True
  while running:
      # Fps
      clock.tick(fps)
      # Eventos
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              running = False
          elif event.type == pygame.MOUSEBUTTONDOWN:
                  # 1 is the left mouse button, 2 is middle, 3 is right.
                  if event.button == 1:
                      # `event.pos` is the mouse position.
                      if player.rect.collidepoint(event.pos):
                          # Increment the number.
                          clicks += 1        
                          Player.speedy = -5
  
  
  
  
      # Updates
      all_sprites.update()
  
  
      # Draw / render X
      screen.fill(black)
      screen.blit(background, background_rect)
      all_sprites.draw(screen)
      draw_text(screen, str(clicks), 18, width / 2, 10)
  
      # Depois de desenhar tudo, "flip" o display
      pygame.display.flip()
  
  pygame.quit()
  </code></pre>
  
  <p>I would like to thank everyone in advance for any help provided
  Bernardo</p>