import pygame, sys, os from pygame.locals import * # Initialize all Pygame modules. pygame.init( ) # Sets up a window 640x480. Returns a surface, in this case, the surface we will use as the display. Screen = pygame.display.set_mode( ( 640, 480 ), HWSURFACE | DOUBLEBUF ) # Sets the title to "Simple Draw". pygame.display.set_caption( 'Simple Draw' ) Drawing = 0 def DrawPixels( ): if Drawing == 1: BeginPos = pygame.mouse.get_pos( ) SincePos = pygame.mouse.get_rel( ) EndPos = ( BeginPos[0] + SincePos[0], BeginPos[1] + SincePos[1] ) pygame.draw.aaline( Screen, ( 255, 255, 255 ), BeginPos, EndPos ) pygame.display.flip( ) def input( events ): for event in events: if event.type == QUIT: sys.exit( 0 ); if event.type == MOUSEBUTTONDOWN: Drawing = 1 if event.type == MOUSEBUTTONUP: Drawing = 0 # Basic Input Loop while True: input( pygame.event.get( ) ) DrawPixels( )