Commit e1f3f450 by BellCodeEditor

auto save

parent 2f104332
Showing with 8 additions and 2 deletions
......@@ -26,6 +26,8 @@ snake_head = right
apples_x=360
apples_y=300
num1=0
num2=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -46,8 +48,10 @@ while True:
snake_head = down
if x==apples_x and y==apples_y:
apples_x=random.randint(0,660)
apples_y=random.randint(0,480)
num1=random.randint(1,22)
num2=random.randint(1,16)
apples_x=num1*30-30
apples_y=num2*30-30
# 设置贪吃蛇的头部坐标
if setheading == "right":
......@@ -59,6 +63,8 @@ while True:
else:
y += 30
position.append((x, y))
if x==apples_x and y==apples_y:
position.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
......
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