Commit 6e0ecd22 by BellCodeEditor

save project

parent 444a6180
Showing with 3 additions and 2 deletions
...@@ -23,7 +23,7 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)] ...@@ -23,7 +23,7 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right" setheading = "right"
snake_head = right snake_head = right
score=0
apple_x=360 apple_x=360
apple_y=300 apple_y=300
...@@ -58,6 +58,7 @@ while True: ...@@ -58,6 +58,7 @@ while True:
if x==apple_x and y==apple_y: if x==apple_x and y==apple_y:
apple_x=random.randint(0,630)//30*30 apple_x=random.randint(0,630)//30*30
apple_y=random.randint(0,450)//30*30 apple_y=random.randint(0,450)//30*30
score+=10
else: else:
position.pop(0) position.pop(0)
position.append((x, y)) position.append((x, y))
...@@ -69,7 +70,7 @@ while True: ...@@ -69,7 +70,7 @@ while True:
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
for i in range(len(position)-1): for i in range(len(position)-1):
screen.blit(body, position[i]) screen.blit(body, position[i])
info="Score:" info="Score:"+str(score)
text=my_font.render(info,True,(0,0,0)) text=my_font.render(info,True,(0,0,0))
screen.blit(text,(500,10)) screen.blit(text,(500,10))
# 将果实画上去 # 将果实画上去
......
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