Commit f995d1db by BellCodeEditor

auto save

parent 2f28ff61
Showing with 12 additions and 2 deletions
......@@ -27,10 +27,14 @@ x,y=240,120
apple_x,apple_y=360,300
# 创建一个位置列表
position=[(180, 90),(180, 120),(210, 120),(x, y)]
position_a=[]
# 创建一个时间监视器
FPSCLOCK=pygame.time.Clock()
info_a="你失败了,请按空格键重新开始游戏。"
text_a=my_font.render(info_a,True,(0,0,0))
# 保持程序运行
while True:
for event in pygame.event.get():
......@@ -51,6 +55,10 @@ while True:
setheading="up"
snake_head=up
for i in range(len(position)):
position_a.append(position[i])
position_a.pop(-1)
# 向右移动
if setheading=="left":
x-=30
......@@ -69,10 +77,11 @@ while True:
score+=10
else:
position.pop(0)
if x<0 or x>630 or y<0 or y>450:
exit()
# screen.blit(text_a,(0,0))
if (x,y) in position_a:
exit()
# 添加元素并删除元素
position.append((x,y))
# 将背景图画上去
......@@ -91,6 +100,7 @@ while True:
info="score"+str(score)
text=my_font.render(info,True,(0,0,0))
screen.blit(text,(400,10))
position_a.clear()
# 设置帧数
FPSCLOCK.tick(3)
......
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