title: Pygame Lightning animation using pygame.timer.set_timer()
body: <p>I am currently trying to produce an animation of lightning using pygame. I planned to have the lightning animation occur every 3 seconds using the pygame.timer.set_timer() module since I will have other animations occurring that are independent of the lightning animation.</p>
  
  <p>For simplicity, I symbolized the lightning with a yellow triangle that elongates. Once it reaches past a certain point, I planned for the yellow triangle to stop, disappear for 3 seconds, before reoccurring again.</p>
  
  <p>However, the lightning_event does not seem to be triggered every time within the while loop, and there is no delay happening.</p>
  
  <p>I have looked at the invaders example using pygame.timer.set_timer(), although it does not use xy coordinates. I tried adjusting the invaders code to use xy coordinates, but it did not work either.</p>
  
  <p>Another question I have is that if there is many events occurring at once, is using multithreading or multiprocessing a better option than using pygame.timer.set_timer()? If so, how can multithreading or multiprocessing be used with the pygame module? Especially because of python's GIL?</p>
  
  <p>Here is my code for the lighting animation:</p>
  
  <pre><code>import pygame
  pygame.init()
  
  BLACK = (0,0,0)
  WHITE = (255,255,255)
  GREEN = (0,255,0)
  RED = (255,0,0)
  BLUE = (0,0,255)
  YELLOW = (200,240,70)
  
  size = (700,500)
  screen = pygame.display.set_mode(size)
  pygame.display.set_caption("Multithreading Project")
  
  done = False
  
  delay1 = 3000 
  clock = pygame.time.Clock()
  
  def lightning(y_coord,y_coord_incr):
      pygame.draw.polygon(screen,YELLOW,[[200,200],[100,y_coord],[300,y_coord]])
  
  lightning_event = pygame.USEREVENT + 1
  pygame.time.set_timer(lightning_event, delay1)
  
  while not done:
      for event in pygame.event.get():
  
          if event.type == pygame.QUIT:
              done = True
          elif event.type == lightning_event:
              if y_coord &gt; 500:
                  y_coord = 200
      screen.fill(WHITE)
      lightning(y_coord,y_coord_incr)
      y_coord = y_coord + y_coord_incr
      pygame.display.flip()
      clock.tick(60)
  pygame.quit()
  </code></pre>
  
  <p>Thank you!</p>