Commit bd82a0ef by BellCodeEditor

save project

parent 87a4021f
Showing with 7 additions and 0 deletions
...@@ -8,6 +8,7 @@ pygame.init() ...@@ -8,6 +8,7 @@ pygame.init()
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
FPSCLOCK=pygame.time.Clock() FPSCLOCK=pygame.time.Clock()
# 背景 # 背景
my_font=pygame.font.Font('neuropol.ttf',20)
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
food = pygame.image.load('apple.png') food = pygame.image.load('apple.png')
...@@ -18,6 +19,7 @@ down = pygame.image.load('down.png') ...@@ -18,6 +19,7 @@ down = pygame.image.load('down.png')
x,y=240, 120 x,y=240, 120
applex=360 applex=360
appley=270 appley=270
score=0
pos=[(180,90),(180,120),(210,120),(x,y)] pos=[(180,90),(180,120),(210,120),(x,y)]
setheading='right' setheading='right'
snake_head = right snake_head = right
...@@ -55,6 +57,7 @@ while True: ...@@ -55,6 +57,7 @@ while True:
num2=random.randint(0,22) num2=random.randint(0,22)
applex=num2*30-30 applex=num2*30-30
appley=num1*30-30 appley=num1*30-30
score+=10
else: else:
pos.pop(0) pos.pop(0)
pos.append((x,y)) pos.append((x,y))
...@@ -70,5 +73,8 @@ while True: ...@@ -70,5 +73,8 @@ while True:
# 将果实画上去 # 将果实画上去
screen.blit(food, (applex, appley)) screen.blit(food, (applex, appley))
# 刷新画面 # 刷新画面
info='Score:'+str(score)
text=my_font.render(info,True,(0,0,0))
screen.blit(text,(530,15))
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