Commit 710cc216 by BellCodeEditor

save project

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