Commit 710cc216 by BellCodeEditor

save project

parent 4388dda7
Showing with 12 additions and 11 deletions
...@@ -25,32 +25,33 @@ while True: ...@@ -25,32 +25,33 @@ while True:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if event.key==K_RIGHT and setheading != "left": if event.key==locals.K_RIGHT and setheading != "left":
setheading="right" setheading="right"
elif event.key==K_LEFT and setheading != "right": elif event.key==locals.K_LEFT and setheading != "right":
setheading="left" setheading="left"
elif event.key==K_UP and setheading != "down" elif event.key==locals.K_UP and setheading != "down":
setheading="up" setheading="up"
else: elif event.key==locals.K_DOWN and setheading != "up":
setheading="down" setheading="down"
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
if setheading=="right": if setheading=="right":
x+=30 x+=30
a=right head=right
elif setheading=="left": elif setheading=="left":
x-=30 x-=30
a=left head=left
elif setheading=="up": elif setheading=="up":
x-=30 y-=30
a=up head=up
else: else:
x+=30 y+=30
a=down head=down
list.append((x,y)) list.append((x,y))
list.pop(0) list.pop(0)
screen.blit(a, (x, y)) screen.blit(head, (x, y))
for i in range(len(list)-1): for i in range(len(list)-1):
screen.blit(body,list[i]) screen.blit(body,list[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