Commit 44927bda by BellCodeEditor

save project

parent 195db8de
Showing with 10 additions and 2 deletions
...@@ -18,6 +18,7 @@ left = pygame.image.load('left.png') # 头 朝左 ...@@ -18,6 +18,7 @@ left = pygame.image.load('left.png') # 头 朝左
up = pygame.image.load('up.png') # 头 朝上 up = pygame.image.load('up.png') # 头 朝上
down = pygame.image.load('down.png') # 头 朝下 down = pygame.image.load('down.png') # 头 朝下
text = pygame.font.Font("neuropol.ttf",20) text = pygame.font.Font("neuropol.ttf",20)
over = pygame.font.Font("neuropol.ttf",40)
x, y = 240, 120 x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)] position = [(180, 90), (180, 120), (210, 120), (x, y)]
...@@ -60,11 +61,13 @@ while True: ...@@ -60,11 +61,13 @@ while True:
Score+=10 Score+=10
else: else:
position.pop(0) position.pop(0)
if x>630 or x<0 or y>450 or y<0:
over_txt=over.render("Game Over",True,(0,0,0))
break
out_score="Score:"+str(Score) out_score="Score:"+str(Score)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将果实画上去
# 将果实画上去
screen.blit(food, (apple_X,apple_Y)) screen.blit(food, (apple_X,apple_Y))
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
screen.blit(snake_head, position[-1]) screen.blit(snake_head, position[-1])
...@@ -76,4 +79,8 @@ while True: ...@@ -76,4 +79,8 @@ while True:
screen.blit(score_txt,(515,0)) screen.blit(score_txt,(515,0))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(ticktime)
screen.blit(over_txt,(175,200))
for i in range(6):
pygame.display.update()
FPSCLOCK.tick(ticktime) FPSCLOCK.tick(ticktime)
\ 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