Commit 2665f4c5 by BellCodeEditor

save project

parent c5f63af4
Showing with 27 additions and 2 deletions
......@@ -10,8 +10,13 @@ pygame.init()
screen=pygame.display.set_mode((660,480))
bg=image.load('bg.png')
right=image.load('right.png')
down=image.load('down.png')
up=image.load('up.png')
left=image.load('left.png')
body=image.load('body.png')
apple=image.load('apple.png')
heading=right
head=right
x,y=240,120
fps=pygame.time.Clock()
position=[(210,60),(240,60),(240,90),(x,y)]
......@@ -19,11 +24,31 @@ while True:
for event in pygame.event.get():
if event.type==locals.QUIT:
exit()
x+=30
if event.type==locals.KEYDOWN:
if event.key==locals.K_UP and heading!='down':
heading='up'
head=up
if event.key==locals.K_DOWN and heading!='up':
heading='down'
head=down
if event.key==locals.K_RIGHT and heading!='left':
heading='right'
head=right
if event.key==locals.K_LEFT and heading!='right':
heading='left'
head=left
if heading=='up':
y-=30
elif heading=='down':
y+=30
elif heading=='left':
x-=30
else :
x+=30
position.append((x,y))
position.pop(0)
screen.blit(bg,(0,0))
screen.blit(right,(x,y))
screen.blit(head,(x,y))
for i in range(len(position)-1):
screen.blit(body,position[i])
screen.blit(apple,(360,120))
......
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