# simple test of pygame # my init shell import pygame, sys # Define some colors black = ( 0, 0, 0) white = ( 255, 255, 255) green = ( 0, 255, 0) red = ( 255, 0, 0) pygame.init() # Set the height and width of the screen size=[640, 480] screen=pygame.display.set_mode(size) pygame.display.set_caption("Demo Python Game") #Loop until the user clicks the close button. done=False end = 0 # Used to manage how fast the screen updates clock=pygame.time.Clock() # -------- Main Game Loop ----------- while done==False: for event in pygame.event.get(): # User did something if event.type == pygame.QUIT: # If user clicked close done=True # Flag that we are done so we exit this loop # Set the screen background screen.fill(white) # Draw on the screen several red lines # 5 pixels wide using a loop pygame.draw.line(screen, red, [410,100],[410,200],7) pygame.draw.line(screen, green, [100,100],[600,400],10) pygame.draw.rect(screen, black, (400,300,50,50)) y_offset=0 while y_offset < 100: pygame.draw.line(screen,red,[110,110+y_offset],[310,310+y_offset],5) y_offset=y_offset+10 # ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT # Limit to 20 frames per second clock.tick(20) # Go ahead and update the screen with what was drawn. pygame.display.flip() # don't hang on exit with IDLE. pygame.quit ()