Commit cb2ed00d by BellCodeEditor

save project

parent 3a2e2fc6
Showing with 26 additions and 0 deletions
...@@ -9,12 +9,38 @@ e=pygame.image.load('bg.png') ...@@ -9,12 +9,38 @@ e=pygame.image.load('bg.png')
b=pygame.image.load('right.png') b=pygame.image.load('right.png')
c=pygame.image.load('apple.png') c=pygame.image.load('apple.png')
d=pygame.image.load('body.png') d=pygame.image.load('body.png')
left=pygame.image.load('left.png')
up=pygame.image.load('up.png')
down=pygame.image.load('down.png')
right_a='right'
right_b=b
x,y=270,120 x,y=270,120
a=[(180,120),(210,120),(240,120),(x,y)] a=[(180,120),(210,120),(240,120),(x,y)]
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()
elif event.type==locals.KEYDOWN:
if event.key==locals.K_RIGHT and right_a !='left':
right_a='right'
right_b=b
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 !='down':
right_a='up'
right_b=up
if event.key==locals.K_UP and right_a !='up':
right_a='down'
right_b=down
if right_a=='right':
x+=30
if right_a=='left':
x-=30
if right_a=='up':
x-=30
if right_a=='down':
x+=30
x+=30 x+=30
a.append((x,y)) a.append((x,y))
a.pop(0) a.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