Pyganim – A Pygame module to make sprite animation dead simple.

Download pyganim.py and example programs. (Works on both Python 2 and 3.)

Details at http://inventwithpython.com/pyganim/

Pyganim is a module that you can import into your Pygame games to handle sprite animation. Creating an animation is simply a matter of supplying a list of image filenames (or pygame.Surface objects) for each frame of animation, along with the duration that each frame lasts. Then call the play() method to start the animation and then call blit() each time you draw the window. The blit() function automatically draws the correct frame based on the amount of real time that has passed since the play() method was called. There are many, many other methods to provide finer levels of control as well.

There is more information available on the Tutorial and Reference page.

3 comments.

  1. Hey, thanks a lot!

  2. Nicely done!
    I tested your example programs and needed to make a slight change for it to run on my machine.
    Here’s what I added:

    import os
    os.system(“Learning Pyganim”)
    MYPATH = os.path.expanduser(“~”)
    os.chdir(os.path.join(MYPATH,”Desktop\\Python\\Pyganim”))
    #This is the folder where I installed PygAnim files

    Then I needed to change all the forward slashes (/) to the double back slash (\\) as in

    ‘testimages/bolt_strike_0001.png’ to
    ‘testimages\\bolt_strike_0001.png’.

    Everything ran great from there. Thanks for all you hard work!!
    Flavio

  3. Where’s the setFrameNum method? It appears to not exist, yet it is in the documentation, but not in any of the examples.

Post a comment.