fps = 10 width = 640 height = 480 # check to see if the pygame module is in the namespace try: pygame except NameError: # pygame doesn't exsist, so import it. # this only happens once. import pygame from pygame.locals import * # initialize the pygame display pygame.init() pygame.display.set_mode((width,height),0,32) display = pygame.display.get_surface() # initialize the pygame clock clk = pygame.time.Clock() def play(): """ Main game logic, called once per frame.""" # fill the display with black. Clears the screen. pygame.draw.rect(display, (0,0,0,255),(0,0,width,height)) # draw a shape. pygame.draw.ellipse(display, (0,40,200,255),(200,200,100,50)) # update the display. pygame.display.flip() # check for events, and return true if we get an exit signal. events = pygame.event.get() for event in events: if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): return True # try to maintain a set frame rate. clk.tick(fps) # No exit signal was recived, so return false. return False