Commit c1f68682 by BellCodeEditor

auto save

parent 1616c066
Showing with 12 additions and 12 deletions
......@@ -17,30 +17,30 @@ food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
a = [(180,90),(180,120),(210,120),(x,y)]
head = right
w = "right"
setheading = "right"
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and w != "left":
if event.key == locals.K_RIGHT and setheading != "left":
head = right
w = "right"
if event.key == locals.K_LEFT and w != "right":
setheading = "right"
if event.key == locals.K_LEFT and setheading != "right":
head = left
w = "left"
if event.key == locals.K_UP and w != "down":
setheading = "left"
if event.key == locals.K_UP and setheading != "down":
head = up
w = "up"
if event.key == locals.K_DOWN and w != "up":
setheading = "up"
if event.key == locals.K_DOWN and setheading != "up":
head = down
w = "down"
if w == "right":
setheading = "down"
if setheading == "right":
x += 30
elif w == "left":
elif setheading == "left":
x -= 30
elif w == "up":
elif setheading == "up":
y -= 30
else:
y +=30
......
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