Commit a0583641 by BellCodeEditor

save project

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