All pastes #343862 Raw Edit

Stuff

public text v1 · immutable
·published 2007-02-07 10:47 UTC
rendered paste body
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' )

ScreenRect = Screen.get_rect( )
OldPos = None
while( 1 ):
    for event in pygame.event.get( ):
        if event.type == QUIT:
            sys.exit( 0 );
        elif event.type == MOUSEBUTTONDOWN and event.button == 1:
            Clicked = pygame.mouse.get_pressed( )
            
            if Clicked[0] == True:
                if not OldPos: 
                    OldPos = pygame.mouse.get_pos()
                    NewPos = OldPos
                else:
                    NewPos = pygame.mouse.get_pos( )
                    pygame.draw.line( Screen, ( 255, 255, 255 ), OldPos, NewPos, 2 )
                    OldPos = NewPos
    
    pygame.display.flip( )