Commit 95323135 by BellCodeEditor

save project

parent 0af9615f
Showing with 11 additions and 16 deletions
...@@ -19,19 +19,14 @@ body = pygame.image.load('body.png') ...@@ -19,19 +19,14 @@ body = pygame.image.load('body.png')
setheading="right" setheading="right"
a=right a=right
while True: while True:
if setheading=='right': if setheading=="right":
x+=30 x=x+30
a=right elif setheading=='left':
elif setheading=='left': x=x-30
x-=30 elif setheading=='down':
a=right y=y+30
elif setheading=='up': else :
y+=30 y=y-30
a=up
elif setheading=='down':
y-=30
a=down
sb.append((x,y)) sb.append((x,y))
sb.pop(0) sb.pop(0)
...@@ -39,15 +34,15 @@ while True: ...@@ -39,15 +34,15 @@ while True:
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 setheading !='left':
setheading='right'
if event.key==locals.K_LEFT and setheading !='right': if event.key==locals.K_LEFT and setheading !='right':
setheading='left' setheading='left'
if event.key==locals.K_RIGHT and setheading !='left':
setheading='right'
if event.key==locals.K_UP and setheading !='down': if event.key==locals.K_UP and setheading !='down':
setheading='up' setheading='up'
if event.key==locals.K_DOWN and setheading !='up': if event.key==locals.K_DOWN and setheading !='up':
setheading='down' setheading='down'
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
......
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