Commit c19981f3 by BellCodeEditor

save project

parent 8aac15a9
Showing with 9 additions and 6 deletions
......@@ -45,11 +45,11 @@ while True:
setheading = 'down'
snake_head = down
if x==a_x and y==a_y:
a_x=random.randint(0,660)
a_y=random.randint(0,480)
pygame.display.update()
a_x=random.randint(0,33)*30
a_y=random.randint(0,16)*30
screen.blit(food, (a_x, a_y))
# 设置贪吃蛇的头部坐标
# 苹果被吃后重新出现
if setheading == "right":
x += 30
elif setheading == "left":
......@@ -58,11 +58,14 @@ while True:
y -= 30
else:
y += 30
#按键控制蛇移动
position.append((x, y))
position.pop(0)
# 将背景图画上去
# 将蛇头的图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去
# 将背景图画上去
screen.blit(snake_head, position[-1])
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
......
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