Commit d32303d1 by BellCodeEditor

save project

parent 6a6f968e
Showing with 19 additions and 1 deletions
......@@ -8,6 +8,7 @@ T=pygame.time.Clock()
screen = pygame.display.set_mode((660, 480))
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
......@@ -15,6 +16,8 @@ food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
x,y=240,120
sdf='right'
asd=[(180, 90),(180, 120),(210, 120),(x, y)]
while True:
......@@ -22,8 +25,23 @@ while True:
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
elif event.type==locals.KEYDOWN:
if event.key==locals.K_RIGHT and sdf!='left':
sdf='right'
if event.key==locals.K_LEFT and sdf!='right':
sdf='left'
if event.key==locals.K_UP and sdf!='down':
sdf='up'
if event.key==locals.K_DOWN and sdf!='up':
sdf='down'
if sdf=='right':
x=x+30
if sdf=='left':
x=x-30
if sdf=='up':
y=y-30
if sdf=='down':
y=y+30
asd.append((x,y))
asd.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