Commit e8d05994 by BellCodeEditor

save project

parent 2d69614f
Showing with 20 additions and 1 deletions
...@@ -14,16 +14,35 @@ food = pygame.image.load('apple.png') ...@@ -14,16 +14,35 @@ food = pygame.image.load('apple.png')
body = pygame.image.load('body.png') body = pygame.image.load('body.png')
x,y=240,120 x,y=240,120
b="right"
d=[(180, 90),(180, 120),(210,120),(x,y)] d=[(180, 90),(180, 120),(210,120),(x,y)]
k=pygame.time.Clock() k=pygame.time.Clock()
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type==locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type==locals.KEYDOWN:
if event.type==locals.K_RIGHT and b!="left":
b="right"
if event.type==locals.K_LEFT and b!="right":
b="left"
if event.type==locals.K_UP and b!="down":
b="up"
if event.type==locals.K_DOWN and b!="up":
b="down"
if b=="right":
x+=30 x+=30
elif b=="left":
x-=30
elif b=="up":
y-=30
else:
y+=30
d.append((x,y)) d.append((x,y))
d.pop(0) d.pop(0)
......
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