Commit a0583641 by BellCodeEditor

save project

parent 949dfda7
Showing with 9 additions and 9 deletions
......@@ -26,16 +26,16 @@ while True:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if event.key==locals.K_RIGHT and sd != left:
if event.key==locals.K_RIGHT and sd != "left":
sd="right"
sh=right
if event.key==locals.K_LEFT and sd != right:
if event.key==locals.K_LEFT and sd != "right":
sd="left"
sh=left
if event.key==locals.K_UP and sd != down:
if event.key==locals.K_UP and sd != "down":
sd="up"
sh=up
if event.key==locals.K_DOWN and sd != up:
if event.key==locals.K_DOWN and sd != "up":
sd="down"
sh=down
# 将背景图画上去
......@@ -43,16 +43,16 @@ while True:
xy.append((x,y))
xy.pop(0)
# 将贪吃蛇画上去
screen.blit(sh, xy[-1])
if sh=="right":
if sd=="right":
x+=30
elif sh=="left":
elif sd=="left":
x-=30
elif sh=="down":
elif sd=="down":
y+=30
else:
y-=30
# 将贪吃蛇的身体画上去
screen.blit(sh, xy[-1])# 将贪吃蛇的身体画上去
for i in range(len(xy)-1):
screen.blit(body,xy[i])
# screen.blit(body, xy[-2])
......
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