Python / Pygame Tutorial 5 - Animation @123Animations
Python / Pygame Tutorial 5 - Animation  @123Animations
Uploaded February 2013 | Updated November 2026, 3 hours ago
In this video I show you how to animate your images. I also show you how to use the clock object to limit the frame rate so the animation is smooth. This is very useful in creating good quality games. Please like the video if you enjoyed! Also please subscribe.

Mario Sprite Sheet (for the mario images):
http://3.bp.blogspot.com/-haGIpD8HV70/UI8b6626YTI/AAAAAAAABuY/nOzTRM7TNdc/s1600/mario33.png

Download this project (with the images):
dropbox.com/s/yo18m55f3ztwg5o/pygameanimation.zip

Code:

import pygame

pygame.init()

window = pygame.display.set_mode((800,600))

pygame.display.set_caption("Animation")

white = (255,255,255)

clock = pygame.time.Clock()

# Mario sprites
m1 = pygame.image.load("images/m1.png")
m2 = pygame.image.load("images/m2.png")

marioCurrentImage = 1

gameLoop=True
while gameLoop:

for event in pygame.event.get():

if (event.type==pygame.QUIT):

gameLoop=False

window.fill(white)

if (marioCurrentImage==1):

window.blit(m1, (10,10))

if (marioCurrentImage==2):

window.blit(m2, (10,10))


if (marioCurrentImage==2):

marioCurrentImage=1

else:

marioCurrentImage+=1;

pygame.display.flip()

clock.tick(10)

pygame.quit()
Python / Pygame Tutorial 5 - AnimationScratch - Mario Tutorial - Adding in a BackgroundPython / Pygame Tutorial - Platformer - Creating the PlayerScratch - How to Put Enemies in your GamePython / Pygame Tutorial 7 - Sprite Class (Part 1/2)Python / Pygame Tutorial 3 - Creating a WindowScratch - Mario Tutorial Part 5Scratch - Mario Tutorial Part 7Scratch - Stopping sprites from moving when they hit a wallScratch - How to make your sprite move over hills
123Animations |

Python / Pygame Tutorial 5 - Animation

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER