Commit 69249b33 by BellCodeEditor

save project

parent 6d056ec4
Showing with 18 additions and 2 deletions
...@@ -15,6 +15,8 @@ background = pygame.image.load('bg.png') ...@@ -15,6 +15,8 @@ background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
food = pygame.image.load('apple.png') food = pygame.image.load('apple.png')
body = pygame.image.load('body.png') body = pygame.image.load('body.png')
body = pygame.image.load('body.png')
body = pygame.image.load('body.png')
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -25,6 +27,19 @@ while True: ...@@ -25,6 +27,19 @@ while True:
a.append((x,y)) a.append((x,y))
a.pop(0) a.pop(0)
print(a) print(a)
if setheading=="r":
x+=30
elif setheading=="l":
x-=30
elif setheading=="up":
y-=30
else :
y+=30
position.append((x,y))
position.pop(0)
if x==apple_x and y==apple_y:
apple_x=r
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
...@@ -40,4 +55,5 @@ while True: ...@@ -40,4 +55,5 @@ while True:
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOOK=pygame.time.Clock() FPSCLOOK=pygame.time.Clock()
FPSCLOOK.tick(FPS) FPSCLOOK.tick(FPS)
\ No newline at end of file
\ No newline at end of file
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