Commit 819f5df9 by BellCodeEditor

save project

parent 3bb2e58c
Showing with 10 additions and 0 deletions
...@@ -29,6 +29,8 @@ class Player(pygame.sprite.Sprite): # 悟空 ...@@ -29,6 +29,8 @@ class Player(pygame.sprite.Sprite): # 悟空
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑") pygame.display.set_caption("悟空酷跑")
ziti=pygame.font.Font('STKAITI.TTF',18)
score_audio=pygame.mixer.Sound('score.wav')
# 载入图片 # 载入图片
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路 road = pygame.image.load('road.png') # 路
...@@ -48,6 +50,7 @@ road_x = 0 ...@@ -48,6 +50,7 @@ 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() # 创建精灵组
...@@ -114,6 +117,13 @@ while True: ...@@ -114,6 +117,13 @@ while True:
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
else:
if (sprite.rect.x+sprite.width)<wukong.rect.x:
score_sprite.score
sprite.score+=0
text=ziti.render ('分数'+str(score),True,(255,255,255))
screen.blit(text,(880,20))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
......
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