From f95d24ea614ec55552775de1a7ce2af58fe4a5f7 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 28 May 2022 20:29:40 +0800 Subject: [PATCH] auto save --- snake.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/snake.py b/snake.py index 0213ada..6489d5a 100644 --- a/snake.py +++ b/snake.py @@ -3,7 +3,7 @@ from pygame import locals import random # 初始化pygame,为使用硬件做准备 pygame.init() - +shengming=3 # 创建一个窗口 screen = pygame.display.set_mode((660, 480)) FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) @@ -61,6 +61,9 @@ while True: score+=1 else: position.pop(0) + if x<0 or x>630 or y<0 or y>450: + shengming-=1 + if shengming # 将背景图画上去 screen.blit(background, (0, 0)) # 将贪吃蛇的头画上去 @@ -76,5 +79,5 @@ while True: screen.blit(food, (apple_x, apple_y)) # 刷新画面 pygame.display.update() - FPSCLOCK.tick(20) + FPSCLOCK.tick(10) \ No newline at end of file -- libgit2 0.25.0