Commit 6267b8ca by BellCodeEditor

save project

parent 6ed01c9a
Showing with 8 additions and 1 deletions
......@@ -8,7 +8,8 @@ pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
my_font=pygame.font.Font('neuropol.ttf',18)
score=0
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') # 头 朝右
......@@ -57,10 +58,12 @@ while True:
n2=random.randint(1,16)
apple_x=n1*30-30
apple_y=n2*30-30
score+=10
else:
position.pop(0)
position.append((x, y))
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去
......@@ -71,6 +74,9 @@ while True:
# 将果实画上去
screen.blit(food, (apple_x,apple_y))
info="Score"+str(score)
text=my_font.render(info,True,(0,0,0))
screen.blit(text,(540,10))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
\ 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