Commit b0072b93 by BellCodeEditor

auto save

parent a61a2238
Showing with 9 additions and 2 deletions
......@@ -25,6 +25,7 @@ pygame.display.set_caption("悟空酷跑")
# 载入图片
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
my_font=pygame.font.Font('STKAITI.TTF',32)
stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌
bush = pygame.image.load('bush.png') # 灌木丛
......@@ -33,7 +34,6 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
myfont=pygame.font.Font('STKAITI.TTF')
road_x=0
bg_x=0
index = 0
......@@ -46,6 +46,8 @@ time=0 #精灵之间的间隔时间
block_list=pygame.sprite.Group() #创建一个精灵组
gamestate=True
score=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -95,7 +97,7 @@ while True:
if time>=60:#0-60大概1秒时间
time=0
num=random.randint(0,50) #等待1秒后,设置一个随机数
if num>20: #如果>20就向列表中添加一个精灵
if num>20: #如果>20就向列表中添加一个精灵
obstacle=Block(stone,cacti,bush)
block_list.add(obstacle)
for sprite in block_list:
......@@ -111,6 +113,10 @@ while True:
if sprite.rect.x+sprite.rect.width<wukong.rect.x:
score+=sprite.score
sprite.score=0
info='分数:'+str(score)
fenshu=my_font.render(info,True,(255,0,0))
screen.blit(fenshu,(800,100))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment