Commit 381b003f by BellCodeEditor

save project

parent 95ca8934
Showing with 10 additions and 2 deletions
...@@ -52,7 +52,14 @@ while True: ...@@ -52,7 +52,14 @@ while True:
y-=30 y-=30
else: else:
y+=30 y+=30
snake.append((x,y)) snake.append((x,y))
for i in range(len(snake)-1):
if snake[-1] == snake[i]:
exit()
if x<0 or x>630 or y<0 or y>450:
exit()
if x==ap1 and y==ap2: if x==ap1 and y==ap2:
ap1=(random.randint(0,21))*30 ap1=(random.randint(0,21))*30
ap2=(random.randint(0,15))*30 ap2=(random.randint(0,15))*30
...@@ -78,6 +85,6 @@ while True: ...@@ -78,6 +85,6 @@ while True:
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(5) FPS.tick(6)
\ 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