title: How do I make a sprite as a gif in pygame?
body: <p>So I have this idea for a game where you dodge projectiles while controlling a helicopter. I am wondering if you can make a sprite appear as a gif, or something along the lines of two images switching every fraction of a second. I know how to make a sprite appear as one image:</p>
  <pre><code>self.surf = pygame.image.load(&quot;example.png&quot;).convert()
  </code></pre>
  <p>But I was wondering if this had an effect:</p>
  <pre><code>self.surf = pygame.image.load(&quot;example.gif&quot;).convert()
  </code></pre>
  <p>Unfortunately, it only displayed the first image in the gif.
  Here is the gif:
  <a href="https://i.stack.imgur.com/QtMn6.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QtMn6.gif" alt="Helicopter.gif" /></a></p>
  <p>Edit: Ok so I looked at the answers and tried to implement them in my code, but then it was all too confusing and I had tried to do something a bit more simple. This is what I came up with:</p>
  <pre><code>    if play == 1:
          self.surf = pygame.image.load(&quot;Image2.png&quot;).convert()
          pygame.display.update()
          play = 2
          time.sleep(.2)
      if play == 2:
          self.surf = pygame.image.load(&quot;Image1.png&quot;).convert()
          pygame.display.update()
          play = 1
          time.sleep(.2)
  </code></pre>
  <p>But, all that did was display the player sprite as image 1. Is there anything I can add to make this work?</p>