2013年8月21日星期三

As strong as a crusher,python game tutorial(2)


# well, after hello world programming, let us try
# something cool as a crusher crush down a tree
#!/usr/bin/env python #-*- coding:utf-8 -*- import pygame, sys from pygame.locals import * # init pygame packet pygame.init() # set up a window using 32 bit color
DISPLAYSURF = pygame.display.set_mode((500, 400), 0, 32)
pygame.display.set_caption('Draw a mobile crusher')

# make up some color
BLACK = (0,0,0)
WHITE = (255,255,255)
RED = (255,0,0)
GREEN = (0,255,255)
BLUE = (0,0,255)
GREEN = (0,255,0)


DISPLAYSURF.fill(WHITE)

# draw a line from (200,250) to (40,80) line-weight is 3
# strong as a crusher, opps...
pygame.draw.line(DISPLAYSURF,RED,(200,250),(40,80),3)

# draw a cricle
pygame.draw.circle(DISPLAYSURF,BLUE,(300,50),20,0)

# draw a rect the four point is (200,150,100,50)
pygame.draw.rect(DISPLAYSURF, GREEN, (200,150,100,50))

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
    pygame.display.update()



http://www.quarryequipments.com/

没有评论:

发表评论