Commit 70ae0ec5 by BellCodeEditor

save project

parent c5c2f5e0
Showing with 10 additions and 10 deletions
......@@ -18,6 +18,7 @@ down = pygame.image.load('down.png')
x,y=240,120
pos=[(180, 90),(210, 120),(240, 120),(x,y)]
setheading='right'
snake_head=right
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -30,28 +31,27 @@ while True:
if event.key==locals.K_LEFT and setheading!='right':
setheading='left'
snake_head=left
if event.key==locals.K_LEFT and setheading!='down':
if event.key==locals.K_UP setheading!='down':
setheading='up'
snake_head=up
if event.key==locals.K_LEFT and setheading!='up':
if event.key==locals.K_DOWNand setheading!='up':
setheading='down'
snake_head=down
x+=30
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, (x,y))
# 将贪吃蛇的身体画上去
if setheading=='right':
x+=30
elif setheading=='left':
x-=30
elif setheading=='up':
x-=30
y-=30
else:
x+=30
y+=30
pos.append((x,y))
pos.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(snake_head, (x,y))
# 将贪吃蛇的身体画上去
screen.blit(body, pos[1])
screen.blit(body, pos[2])
screen.blit(body, pos[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