Turtle Collisions
& how to borrow code, the smart way
Published in
2 min readApr 23, 2018
→ Lab Assignment: “Get them coins” on repl.it
# how to check for turtle/coin collision, using the Euclidean distance formulawhile True:
distance = math.sqrt((player.xcor() - coin.xcor())**2 + (player.ycor() - coin.ycor())**2)
if distance < 20 :
coin.sety(coin.ycor() + 20)
coin.hideturtle()
score = score + 1