diff --git a/snake.py b/snake.py index 96661ec..9fd8467 100644 --- a/snake.py +++ b/snake.py @@ -17,8 +17,8 @@ body = pygame.image.load('body.png') # 身体 left = pygame.image.load('left.png') # 头 朝左 up = pygame.image.load('up.png') # 头 朝上 down = pygame.image.load('down.png') # 头 朝下 -my-font= - +my_font=pygame.font.Font('neuropol.ttf',18) +score=0 x, y = 240, 120 position = [(180, 90), (180, 120), (210, 120), (x, y)] apple_x,apple_y=240,300 @@ -57,6 +57,7 @@ while True: if x==apple_x and y==apple_y: apple_x=randint(1,21)*30 apple_y=randint(1,15)*30 + score+=10 position.pop(0) # 将背景图画上去 screen.blit(background, (0, 0)) @@ -67,7 +68,10 @@ while True: screen.blit(body, position[i]) # 将果实画上去 + info='score'+str(score) screen.blit(food, (apple_x,apple_y )) + text=my_font.render(info,True,(200,0,0)) + screen.blit(text,(500,30)) # 刷新画面 pygame.display.update() FPSCLOCK.tick(3) \ No newline at end of file