User Tools

Site Tools


user:bh011695:pygametutorial:line.py
#lines.py
#
#Drawing lines to the screen
#
#
import pygame
 
screen = pygame.display.set_mode((640, 480))	#pygame surface 640 X 480
clock = pygame.time.Clock()			#pygame clock
pygame.display.set_caption("pygame window")	#pygame window title
BG_COLOR = (0, 0, 0)				#RGB value for black
LINE_COLOR = (0, 255, 0)			#RGB value for green
FPS = 60      					#Sets the framerate
running = True					#Game loop executes while running is true
 
while running:
	screen.fill(BG_COLOR)	#Fills screen
 
        #Draws a line from the top left corner of the window to the bottom
	#right corner. The draw line function works as follows:
	#pygame.draw.line(screen, lineColor, starting x and y, stopping x and y)
	pygame.draw.line(screen, LINE_COLOR, (0, 0), (640, 480))
 
	pygame.display.flip()
	clock.tick(FPS)
user/bh011695/pygametutorial/line.py.txt · Last modified: 2010/12/15 04:56 by bh011695