Commit 18511e14 by BellCodeEditor

save project

parent 7de20221
Showing with 25 additions and 1 deletions
......@@ -12,21 +12,45 @@ background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
up = pygame.image.load('up.png')
down = pygame.image.load('down.png')
right = pygame.image.load('right.png')
x,y =240,120
buckethead=[(180,90),(180,120),(210,120),(x,y)]
setheading="right"
bucket=pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.key == locals.KEYDOWN:
if event.key == locals.K_RIGHT and setheading !="left":
setheading="right"
ghj="right"
if event.key == locals.K_LEFT and setheading !="right":
setheading='left'
ghj=left
if event.key == locals.K_UP and setheading !="down":
setheading='up'
ghj=up
if event.key == locals.DOWN and setheading !="up":
setheading='down'
ghj=down
if event.key == locals.K_RIGHT and !="left"
setheading='right'
ghj="right"
x += 30
buckethead.append((x,y))
buckethead.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, buckethead(-1)
screen.blit(right, buckethead[-1])
# 将贪吃蛇的身体画上去
for i in range(len(buckethead)-1):
......
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