From e14a0d3600b748b207261764453bc39cf79d060e Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 16 Mar 2024 20:05:13 +0800 Subject: [PATCH] save project --- snake.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/snake.py b/snake.py index 6a3ea38..6f3ba73 100644 --- a/snake.py +++ b/snake.py @@ -25,7 +25,7 @@ apple_x = 360 apple_y = 360 setheading = "right" snake_head = right - +score = 0 while True: for event in pygame.event.get(): if event.type == locals.QUIT: @@ -59,8 +59,8 @@ while True: # 将背景图画上去 screen.blit(background, (0, 0)) if x == apple_x and y == apple_y: - num1 = random.randint(1,16) - num2 = random.randint(1,16) + apple_x = random.randint(1,16) + apple_y = random.randint(1,16) apple_x = num1 * 30 - 30 apple_y = num2 * 30 - 30 @@ -78,4 +78,5 @@ while True: pygame.display.update() FPSCLOCK.tick(3) info = "Score"+ str(score) - text = my_font.render(info, True, (0,0,0)) \ No newline at end of file + text = my_font.render(info, True, (0,0,0)) + score.blit -- libgit2 0.25.0