title: In PyGame, how to move an image every 3 seconds without using the sleep function?
body: <p>Recently I've learned some basic Python, so I am writing a game using PyGame to enhance my programming skills.</p>
  
  <p>In my game, I want to move an image of a monster every 3 seconds, at the same time I can aim it with my mouse and click the mouse to shoot it.</p>
  
  <p>At the beginning I tried to use <strong>time.sleep(3)</strong>,   but it turned out that it pause the whole program, and I can't click to shoot the monster during the 3 seconds.</p>
  
  <p>So do you have any solution for this?</p>
  
  <p>Thanks in advance! :)</p>
  
  <hr>
  
  <p>Finally I solved the problem with the help of you guys. Thank you so much!
  Here is part of my code:</p>
  
  <pre><code>import random, pygame, time
  
  x = 0
  t = time.time()
  while True:
  
      screen = pygame.display.set_mode((1200,640))
      screen.blit(bg,(0,0))
  
      if time.time() &gt; t + 3:
          x = random.randrange(0,1050)
          t = time.time()
  
      screen.blit(angel,(x,150))
  
      pygame.display.flip() 
  </code></pre>