Commit 3ba1a74f by BellCodeEditor

auto save

parent a2f39897
Showing with 7 additions and 7 deletions
...@@ -17,7 +17,8 @@ body = pygame.image.load('body.png') # 身体 ...@@ -17,7 +17,8 @@ body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.png') # 头 朝左 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') # 头 朝下
pygame.font.Font('neuropol.ttf',size) my_font = pygame.font.Font('neuropol.ttf',18)
score = 0
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,9 +57,9 @@ while 1==1: ...@@ -56,9 +57,9 @@ while 1==1:
y += 30 y += 30
position.append((x, y)) position.append((x, y))
if apple_x == x and apple_y == y: if apple_x == x and apple_y == y:
num1 = random.randint(1,21) num1 = random.randint(1,22)
apple_x = num1 * 30 apple_x = num1 * 30
num2 = random.randint(0,15) num2 = random.randint(1,12)
apple_y = num2 * 30 apple_y = num2 * 30
else: else:
position.pop(0) position.pop(0)
...@@ -74,9 +75,8 @@ while 1==1: ...@@ -74,9 +75,8 @@ while 1==1:
screen.blit(food, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
#将分数画上去 #将分数画上去
info = "Score" + str(score) info = "Score" + str(score)
text = pygame.font.Font('Score:10',True,(0,0,0)) text = my_font.render(info,True,(0,0,0))
screen.blit(text,(540,10)) screen.blit(text,(540,10))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(15) FPSCLOCK.tick(15)
\ 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