Commit 547138c6 by BellCodeEditor

save project

parent 9e6f11d8
Showing with 6 additions and 6 deletions
...@@ -3,16 +3,15 @@ from pygame import locals ...@@ -3,16 +3,15 @@ from pygame import locals
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
x,y=240,120
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
b=[(270,150),(270,120),(x,y)]
# 背景 # 背景
background = pygame.image.load('bg.png') 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')
a=pygame.time.Clock() a=pygame.time.Clock()
x,y=240,120
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -20,12 +19,13 @@ while True: ...@@ -20,12 +19,13 @@ while True:
exit() exit()
# 将背景图画上去\ # 将背景图画上去\
x+=30 x+=30
b.append((x,y))
b.pop(0)
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(right, (x,y)) screen.blit(right, (x,y))
screen.blit(right, (270,120)) for i in range(len(b)-1):
screen.blit(right, (270,150)) screen.blit(right, (b[i]))
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
# 将果实画上去 # 将果实画上去
......
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