Python with turtle, move turtle from one spot to another
It's a really simple question, though I didn't find a solution. I want that when the turtle reaches a certain position, I use a command to move it to another position. The command I use is:
while turtle.xcor() and turtle.ycor() == **: turtle.goto()
But it seems it doesn't work...
I want that when the turtle reaches a certain position, I use a command to move it to another position.
The turtle walks a floating point plane so doing exact (integer) position comparisons is problematic. Instead, calculate the distance between the turtle and its target. If that distance is less than some small value (say the radius of the turtle cursor) consider it having hit the target and then take action:
if turtle.distance(-25, 50) < 5: # turtle is upon the target turtle.goto(100, 100)