Commit b9462410 by BellCodeEditor

save project

parent b5da968f
Showing with 4 additions and 2 deletions
...@@ -14,6 +14,7 @@ class Block(pygame.sprite.Sprite): # 障碍物精灵类 ...@@ -14,6 +14,7 @@ class Block(pygame.sprite.Sprite): # 障碍物精灵类
# 障碍物绘制坐标 # 障碍物绘制坐标
self.rect.x = 1000 self.rect.x = 1000
self.rect.y = 500 - self.rect.height self.rect.y = 500 - self.rect.height
self.score=1
class Player(pygame.sprite.Sprite): # 悟空 class Player(pygame.sprite.Sprite): # 悟空
def __init__(self, image): def __init__(self, image):
...@@ -47,11 +48,12 @@ t = 30 ...@@ -47,11 +48,12 @@ t = 30
road_x = 0 road_x = 0
bg_x = 0 bg_x = 0
time = 0 time = 0
score=0
gamestate = True gamestate = True
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
bacis_fout=pygame.fout.Font() basic_font=pygame.font.Font('STKAITI.TTF',18)
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:
...@@ -119,7 +121,7 @@ while True: ...@@ -119,7 +121,7 @@ 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
scoreSurf=basic_font.render('分数:'+str(score),True,(120,134,25)) scoreSurf=basic_font.render('分数:'+str(score),True,(255,255,255))
screen.blit(scoreSurf,(880,20)) screen.blit(scoreSurf,(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