Friday, August 5, 2011

I did my first animation with pygame!

I used the nano text editor to write my first animation using pygame. I downloaded a png file from google images.

#!/usr/bin/python
import sys, pygame
pygame.init()
size = width, height = 600,600
black = 0,0,0
screen = pygame.display.set_mode(size)

tux = pygame.image.load("tux2.png")
x = 0y = 0

while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:sys.exit()

    screen.fill(black)
    screen.blit(tux,(200,200))
    screen.blit(tux,(x,y))

    pygame.display.flip()
    x = x+1
    y = y+1

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.