Commit b0072b93 by BellCodeEditor

auto save

parent a61a2238
Showing with 8 additions and 1 deletions
...@@ -25,6 +25,7 @@ pygame.display.set_caption("悟空酷跑") ...@@ -25,6 +25,7 @@ pygame.display.set_caption("悟空酷跑")
# 载入图片 # 载入图片
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路 road = pygame.image.load('road.png') # 路
my_font=pygame.font.Font('STKAITI.TTF',32)
stone = pygame.image.load('stone.png') # 石头 stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌 cacti = pygame.image.load('cacti.png') # 仙人掌
bush = pygame.image.load('bush.png') # 灌木丛 bush = pygame.image.load('bush.png') # 灌木丛
...@@ -33,7 +34,6 @@ hero = [pygame.image.load('hero1.png'), ...@@ -33,7 +34,6 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
myfont=pygame.font.Font('STKAITI.TTF')
road_x=0 road_x=0
bg_x=0 bg_x=0
index = 0 index = 0
...@@ -46,6 +46,8 @@ time=0 #精灵之间的间隔时间 ...@@ -46,6 +46,8 @@ time=0 #精灵之间的间隔时间
block_list=pygame.sprite.Group() #创建一个精灵组 block_list=pygame.sprite.Group() #创建一个精灵组
gamestate=True gamestate=True
score=0 score=0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -111,6 +113,10 @@ while True: ...@@ -111,6 +113,10 @@ while True:
if sprite.rect.x+sprite.rect.width<wukong.rect.x: if sprite.rect.x+sprite.rect.width<wukong.rect.x:
score+=sprite.score score+=sprite.score
sprite.score=0 sprite.score=0
info='分数:'+str(score)
fenshu=my_font.render(info,True,(255,0,0))
screen.blit(fenshu,(800,100))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) 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