Commit 96b78aa0 by BellCodeEditor

save project

parent 8cce2d1e
Showing with 8 additions and 3 deletions
...@@ -4,7 +4,7 @@ x=240 ...@@ -4,7 +4,7 @@ x=240
y=120 y=120
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
bodys=[(180, 90),(180, 120),(210, 120), (x,y)]
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
...@@ -23,14 +23,18 @@ while True: ...@@ -23,14 +23,18 @@ while True:
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(right, (x,y)) screen.blit(right,bodys[-1])
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
# screen.blit(body, (210, 120)) # screen.blit(body, (210, 120))
# screen.blit(body, (180, 120)) # screen.blit(body, (180, 120))
# screen.blit(body, (180, 90)) # screen.blit(body, (180, 90))
# 将果实画上去 # 将果实画上去
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
for i in range(len(bodys)-1):
screen.blit(body,bodys[i])
x+=30 x+=30
F.tick(3) bodys.pop(0)
bodys.append((x,y))
F.tick(5)
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
\ 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