Commit bfdc9888 by BellCodeEditor

auto save

parent bce3be47
Showing with 14 additions and 7 deletions
...@@ -17,6 +17,8 @@ left = pygame.image.load('left.png') # 头 朝左 ...@@ -17,6 +17,8 @@ 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') # 头 朝下
My_font = pygame.font.Font("neuropol.ttf",30) My_font = pygame.font.Font("neuropol.ttf",30)
a = pygame.font.Font("neuropol.ttf",50)
Over = a.render("GAME OVER",True,(50,50,50))
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)]
...@@ -56,8 +58,8 @@ while True: ...@@ -56,8 +58,8 @@ while True:
else: else:
y += 30 y += 30
position.append((x, y)) position.append((x, y))
position.pop(0)
if x == apple_x or apple_y == y: if x == apple_x and apple_y == y:
num1 = random.randint(1,22) num1 = random.randint(1,22)
num2 = random.randint(1,16) num2 = random.randint(1,16)
apple_x = num1*30-30 apple_x = num1*30-30
...@@ -76,9 +78,14 @@ while True: ...@@ -76,9 +78,14 @@ while True:
# 将果实画上去 # 将果实画上去
screen.blit(food, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
text = "SCORE:"+str(score) text = "SCORE"+str(score)
MyScore = My_font.render(text,True,(0,0,0)) MyScore = My_font.render(text,True,(50,50,50))
screen.bilt(MyScore,(450,10)) screen.blit(MyScore,(450,10))
if x<0 or x>630 or y<0 or y>450:
screen.blit(Over,(100,140))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(2) FPSCLOCK.tick(10)
\ 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