import pygame def initialize(): """ This function sets some global constants (i.e., the values of these global variables never change). """ pygame.init() # set up the display window global width, height, screen width = 640 height = 480 screen = pygame.display.set_mode((width,height)) # load the pictures global guy guy = pygame.image.load("WalkingSquare1.gif") guy = guy.convert() def run_game(): # initialize the guy's position and speed g_x = 100 g_y = 100 g_speed_x = 0 g_speed_y = 0 # start clock clock = pygame.time.Clock() keepGoing = True while (keepGoing): dt = clock.tick() # go through all events that happened and check ... for event in pygame.event.get(): # ... whether the event was a quit event if event.type == pygame.QUIT: keepGoing = False # set background color screen.fill(pygame.color.Color("green")) # draw image screen.blit(guy,(g_x,g_y)) # update display pygame.display.update() def done(): pygame.quit() def main(): initialize() run_game() done() main()