Commit 84728d8f by BellCodeEditor

save project

parent 0d547316
Showing with 10 additions and 1 deletions
......@@ -16,7 +16,10 @@ food = pygame.image.load('apple.png') # 食物 苹果
body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.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', 18) # 字体
# 头 朝下
score = 0
apple_x=360
apple_y=300
x, y = 240, 120
......@@ -56,6 +59,7 @@ while True:
position.append((x, y))
if x == apple_x and y == apple_y:
score+=1
gz_x=random.randint(1,22)
gz_y=random.randint(1,16)
apple_x=gz_x*30-30
......@@ -74,6 +78,10 @@ while True:
# 将果实画上去
screen.blit(food, (apple_x, apple_y))
info = "Score:"+ str(score)
text = my_font.render(info, True, (0, 0, 0))
screen.blit(text, (540, 10))
# 刷新画面
pygame.display.update()
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