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