From 72d9b5dd7afac8eea37e39611fa69cc92b3af013 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 30 Oct 2021 19:56:39 +0800 Subject: [PATCH] save project --- snake.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/snake.py b/snake.py index 0012ecc..0002579 100644 --- a/snake.py +++ b/snake.py @@ -23,6 +23,8 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)] setheading = "right" snake_head = right food_x,food_y=360,300 +my_font=pygame.font.Font('neuropol.ttf',25) +score=0 while True: for event in pygame.event.get(): if event.type == locals.QUIT: @@ -54,7 +56,8 @@ while True: position.append((x, y)) if x==food_x and y==food_y: food_x=random.randint(0,21)*30 - food_y=random.randint(0,15)*30 + food_y=random.randint(0,15)*30 + score+=10 else: position.pop(0) # 将背景图画上去 @@ -67,6 +70,8 @@ while True: # 将果实画上去 screen.blit(food, (food_x, food_y)) + text=my_font.render('Score:'+str(score),True,(0,0,0)) + screen.blit(text,(540,10)) # 刷新画面 pygame.display.update() FPSCLOCK.tick(3) \ No newline at end of file -- libgit2 0.25.0