当Python乌龟与食物碰撞时,为什么我的分数没有更新,我需要帮助。我还在下面发布了带有完整代码的链接:
if turtle.distance(food) < 20:
food.goto(randint(-280,280),randint(-280,280))
# Adding sections
new_section = Turtle()# Turtle() is the same as turtle.Turtle()
new_section.shape('square')
new_section.speed(0)
new_section.color('orange','grey')
new_section.penup()
new_section.goto(old_position)
sections.append(new_section)# Adds new section of body at the end of body
# Score
score = 0
high_score = 0
# Increase the score
score = + 10
if score > high_score:
high_score = score
pen.clear()
pen.write("Score: {} High Score: {}".format(score,high_score),align="center",font=("Courier",24,"normal"))
***Need help on updating score have also posted link below***
screen.update()
screen.ontimer(move,DELAY)
pastebin.com查看完整代码。