Commit 86221ba2 by BellCodeEditor

save project

parent 334c5b58
Showing with 16 additions and 4 deletions
......@@ -24,7 +24,9 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
snake_head = right
score=0
text=pygame.font.Font('neuropol.ttf',18)
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -59,10 +61,13 @@ while True:
n2=random.randint(1,16)
apple_x=n1*30-30
apple_y=n2*30-30
score+=10
else:
position.pop(0)
if x<0 or x>630 or y<0 or y>450:
exit()
......@@ -73,9 +78,16 @@ while True:
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
screen.blit(body, position[i])
if position[i]==position[-1]:
exit()
text1=text.render('Score:'+str(score),True,(0,0,0))
screen.blit(text1,(540,0))
# 将果实画上去
screen.blit(food, (apple_x, apple_y))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
\ No newline at end of file
FPSCLOCK.tick(5)
\ 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