Commit f95d24ea by BellCodeEditor

auto save

parent 6640467d
Showing with 6 additions and 2 deletions
...@@ -3,7 +3,7 @@ from pygame import locals ...@@ -3,7 +3,7 @@ from pygame import locals
import random import random
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
shengming=3
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
...@@ -61,6 +61,9 @@ while True: ...@@ -61,6 +61,9 @@ while True:
score+=1 score+=1
else: else:
position.pop(0) position.pop(0)
if x<0 or x>630 or y<0 or y>450:
shengming-=1
if shengming
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
...@@ -76,5 +79,5 @@ while True: ...@@ -76,5 +79,5 @@ while True:
screen.blit(food, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(20) FPSCLOCK.tick(10)
\ 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