import pygame, sys from pygame.locals import * ''' #0 load and display image #1 Animation #2 FPS control pygame.init() #2 FPS = 30 # frames per second setting #2 fpsClock = pygame.time.Clock() # set up the window screen = pygame.display.set_mode((800, 64), 0, 32) pygame.display.set_caption('Animation') WHITE = (255, 255, 255) circleImg = pygame.image.load('circle64.png') circlex = circley = 0 #1 dir = 1 while True: # the main game loop screen.fill(WHITE) #1 circlex = circlex + dir #1 if circlex > 736 or circlex < 0: #1 dir = -1 * dir screen.blit(circleImg, (circlex, circley)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update() #2 fpsClock.tick(FPS)