Commit da29a846 by BellCodeEditor

save project

parent 49217b03
Showing with 7 additions and 1 deletions
...@@ -8,7 +8,8 @@ pygame.init() ...@@ -8,7 +8,8 @@ pygame.init()
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
setheading="right" setheading="right"
my_font=pygame.font.Font("neuropol.ttf",30)
score=0
# 背景 # 背景
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
...@@ -65,6 +66,7 @@ while True: ...@@ -65,6 +66,7 @@ while True:
num2=random.randint(0,15) num2=random.randint(0,15)
apple_x=num1*30 apple_x=num1*30
apple_y=num2*30 apple_y=num2*30
score+=10
else: else:
position.pop(0) position.pop(0)
...@@ -82,6 +84,10 @@ while True: ...@@ -82,6 +84,10 @@ while True:
# screen.blit(body, (180, 90)) # screen.blit(body, (180, 90))
# 将果实画上去 # 将果实画上去
screen.blit(food, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
# 渲染文字
info="score"+str(score)
text=my_font.render(info,True,(0,0,0))
screen.blit(text,(400,10))
# 设置帧数 # 设置帧数
FPSCLOCK.tick(3) FPSCLOCK.tick(3)
......
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