Commit 0af22f98 by BellCodeEditor

save project

parent 9e28e649
Showing with 26 additions and 2 deletions
......@@ -6,19 +6,43 @@ pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
a=pygame.time.Clock()
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
x,y=210, 120
lift=pygame.image.load('lift.png')
up=pygame.image.load('up.png')
down=pygame.image.load('down.png')
right_a='right'
right_b=right
x,y=240, 120
a_b=[(120,120),(150,120),(180,120),(x,y)]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
elif event.type == locals.KEYDOWN:
if event.key ==locals.K_RIGHT and right_a !='left':
right_a=='right'
right_b=right
if event.key ==locals.K_LEFT and right_a !='right':
right_a=='left'
right_b==left
if event.key ==locals.K_DOWN and right_a !='up':
right_a=='down'
right_b==down
if event.key ==locals.K_ and right_a !='down':
right_a=='up'
right_b==up
if right_a=='light':
x+=30
if left_a=='left':
x-=30
x+=30
a_b.append((x,y))
a_b.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