Commit d28f396c by BellCodeEditor

save project

parent cd317262
Showing with 7 additions and 3 deletions
...@@ -48,9 +48,9 @@ road_x = 0 ...@@ -48,9 +48,9 @@ road_x = 0
bg_x = 0 bg_x = 0
time = 0 time = 0
gamestate = True gamestate = True
score=0
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
f=pygame.font.Font('STKAITI.TTF',20)
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:
...@@ -109,12 +109,15 @@ while True: ...@@ -109,12 +109,15 @@ while True:
sprite.rect.x -= 8 sprite.rect.x -= 8
screen.blit(sprite.image, (sprite.rect.x, sprite.rect.y)) screen.blit(sprite.image, (sprite.rect.x, sprite.rect.y))
if sprite.rect.x <= 0-sprite.rect.width: if sprite.rect.x <= 0-sprite.rect.width:
score+=1
sprite.kill() sprite.kill()
if pygame.sprite.collide_rect(wukong, sprite): # 精灵碰撞检测 if pygame.sprite.collide_rect(wukong, sprite): # 精灵碰撞检测
gameover = pygame.image.load('gameover.png') # 游戏结束 gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover, (400, 200)) screen.blit(gameover, (400, 200))
gamestate = False gamestate = False
word='分数:'+str(score)
text=f.render(word,True,(0,0,0))
screen.blit(text,(0,0))
# 刷新画面 # 刷新画面
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