Commit d91e5ad0 by BellCodeEditor

save project

parent c3d7842a
Showing with 9 additions and 4 deletions
...@@ -54,10 +54,14 @@ while True: ...@@ -54,10 +54,14 @@ while True:
else: else:
y += 30 y += 30
if x==ax and y==ay: if x==ax and y==ay:
ax=random.randint(0,600) sx=random.randint(1,22)
ay=random.randint(0,480) sy=random.randint(1,15)
position.append((x, y)) ax=sx*30-30
ay=sy*30-30
else:
position.pop(0) position.pop(0)
position.append((x, y))
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
...@@ -67,7 +71,7 @@ while True: ...@@ -67,7 +71,7 @@ while True:
screen.blit(body, position[i]) screen.blit(body, position[i])
# 将果实画上去 # 将果实画上去
screen.blit(food, (ax, ay)) screen.blit(food, (ax,ay))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) 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