Commit 8ba8edab by BellCodeEditor

save project

parent 0de2f07d
Showing with 8 additions and 0 deletions
...@@ -69,6 +69,12 @@ while True: ...@@ -69,6 +69,12 @@ while True:
score += 10 score += 10
else: else:
position.pop(0) position.pop(0)
if x<0 or x>630 or y<0 or y>450:
text1 = myFont.render("Game Over!" , True , (0,0,0))
screen.blit(text1,(330,240))
exec()
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
screen.blit(snake_head, position[-1]) screen.blit(snake_head, position[-1])
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
...@@ -79,6 +85,7 @@ while True: ...@@ -79,6 +85,7 @@ while True:
screen.blit(food, (apple_X,apple_y)) screen.blit(food, (apple_X,apple_y))
text = myFont.render("score" + str(score) , True , (0,0,0)) text = myFont.render("score" + str(score) , True , (0,0,0))
screen.blit(text,(540,10)) screen.blit(text,(540,10))
# 刷新画面 # 刷新画面
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