http://down001.6m5m.com/data/uploads/2015/06/24/15171558a48c9e34a4.zip import pygame
pygame.init()
class Game:
#新建窗体
screen = pygame.display.set_mode((480,700))
#设置标题
pygame.display.set_caption("飞机大战")
#创建游戏时钟
clock = pygame.time.Clock
#加载图片数据
bg = pygame.image.load("./images/background.png")
hero1 = pygame.image.load("./images/hero1.png")
#设置图片坐标和长宽
hero1_rect = pygame.Rect(150,300,102,126)
#游戏循环
while True:
#检测游戏事件
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
#每秒钟刷新一次
clock.tick(1)
#显示图片
screen.blit(bg,(0,0))
screen.blit(hero1,hero1_rect)
hero1_rect.y += 1
pygame.display.update()

|