Commit b9d10501 by BellCodeEditor

save project

parent 2416f8cb
Showing with 10 additions and 2 deletions
...@@ -40,7 +40,15 @@ while True: ...@@ -40,7 +40,15 @@ while True:
if event.key == locals.K_DOWN and setheading !="up": if event.key == locals.K_DOWN and setheading !="up":
setheading = 'down' setheading = 'down'
snake_head = down snake_head = down
x +=30 if setheading =="right":
x +=30
elif setheading == "left":
x-=30
elif setheading == "up":
y-=30
else :
y+=30
position.append((x,y)) position.append((x,y))
position.pop(0) position.pop(0)
...@@ -48,7 +56,7 @@ while True: ...@@ -48,7 +56,7 @@ while True:
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(right, (x, y)) screen.blit(snake_head, (x, y))
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
for i in range(len(position)-1): for i in range(len(position)-1):
screen.blit(body,position[i]) screen.blit(body,position[i])
......
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