Commit a3ae023b by BellCodeEditor

save project

parent f9fe7aee
Showing with 7 additions and 1 deletions
...@@ -15,12 +15,14 @@ body = pygame.image.load('body.png') ...@@ -15,12 +15,14 @@ body = pygame.image.load('body.png')
left=pygame.image.load('left.png') left=pygame.image.load('left.png')
down=pygame.image.load('down.png') down=pygame.image.load('down.png')
up=pygame.image.load('up.png') up=pygame.image.load('up.png')
my_font=pygame.font.Font("neuropol.ttf",18)
x,y=240,120 x,y=240,120
position=[(210,120),(180,120),(180,90),(x,y)] position=[(210,120),(180,120),(180,90),(x,y)]
setheading='right' setheading='right'
snakehead=right snakehead=right
apple_x=360 apple_x=360
apple_y=300 apple_y=30
score=0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -57,6 +59,7 @@ while True: ...@@ -57,6 +59,7 @@ while True:
num_2=random.randint(1,12) num_2=random.randint(1,12)
apple_x=num_1*30-30 apple_x=num_1*30-30
apple_y=num_2*30-30 apple_y=num_2*30-30
score+=1
else: else:
position.pop(0) position.pop(0)
...@@ -73,6 +76,9 @@ while True: ...@@ -73,6 +76,9 @@ while True:
#screen.blit(body, (180, 90)) #screen.blit(body, (180, 90))
# 将果实画上去 # 将果实画上去
screen.blit(food, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
info="Score"+str(score)
text=my_font.render(info,True,(250,120,210))
screen.blit(text,(540,10))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
a.tick(5) a.tick(5)
......
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