Commit 3ec13ad4 by BellCodeEditor

save project

parent 7989d574
Showing with 8 additions and 6 deletions
...@@ -58,10 +58,12 @@ while True: ...@@ -58,10 +58,12 @@ while True:
position.append((x, y)) position.append((x, y))
if x==ax and y==ay: if x==ax and y==ay:
ax = random.randint(0,660) n1 = random.randint(1,22)
ay = random.randint(0,480) n2 = random.randint(1,16)
ax = n1 * 30 - 30
position.pop(0) ay = n2 * 30 - 30
else:
position.pop(0)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
...@@ -74,4 +76,4 @@ while True: ...@@ -74,4 +76,4 @@ while True:
screen.blit(food, (ax, ay)) screen.blit(food, (ax, ay))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(5)
\ 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