Commit 8a7b7b37 by BellCodeEditor

save project

parent f0a5f6c9
Showing with 11 additions and 8 deletions
......@@ -7,7 +7,7 @@ pygame.init()
# 创建一个窗口
FPSCLOCK=pygame.time.Clock()
screen = pygame.display.set_mode((660, 480))
muffin = pygame.display.set_mode((660, 480))
# 背景
background = pygame.image.load('bg.png')
......@@ -15,6 +15,7 @@ right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
x, y = 240, 120
muffinb = [(180,90), (180,120), (210,120), (x, y)]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -22,16 +23,17 @@ while True:
exit()
# 将背景图画上去
x += 30
screen.blit(background, (0, 0))
muffinb.append((x, y))
muffinb.pop(0)
muffin.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, (x, y))
muffin.blit(right, muffinb[-1])
for i in range(len(muffinb)-1):
# 将贪吃蛇的身体画上去
screen.blit(body, (210, 120))
screen.blit(body, (180, 120))
screen.blit(body, (180, 90))
muffin.blit(body, muffinb[i])
# 将果实画上去
screen.blit(food, (360, 300))
muffin.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
\ 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