Commit 72d9b5dd by BellCodeEditor

save project

parent 5dc13428
Showing with 7 additions and 1 deletions
......@@ -23,6 +23,8 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
snake_head = right
food_x,food_y=360,300
my_font=pygame.font.Font('neuropol.ttf',25)
score=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -54,7 +56,8 @@ while True:
position.append((x, y))
if x==food_x and y==food_y:
food_x=random.randint(0,21)*30
food_y=random.randint(0,15)*30
food_y=random.randint(0,15)*30
score+=10
else:
position.pop(0)
# 将背景图画上去
......@@ -67,6 +70,8 @@ while True:
# 将果实画上去
screen.blit(food, (food_x, food_y))
text=my_font.render('Score:'+str(score),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