python - How to stop turtles at certain coordinates? -


I am very new to programming (using Python 3) I want to know that the turtle should reach a specific point How to prevent the cuttle during, when I have been able to do it while using the keypresses, but it works only once or twice because turtle X coordination happens when I run it for a while Let me go, for example 40.00 Instead of turtle-40.0001 or -39.9996 the land will be land.

import turtle wn = turtle Screen () a = Turtle. Turtle () def: (): a.setheading (90) if a.pos ()! = (40.00, 80.00): A.forward (20) Other: wrong def (): a.setheading (180) a.forward (20) def correct (): a.setheading (0) a.forward (20) def Down (): a (right, "right") wn.keykey (bottom, "bottom"), Wn.listen () wn.mainloop ()

Right now I'm turtle (- 40.00, 80.00) to stop. Thanks

status directly, instead check that a.distance (40.0, 80.0) & lt; 1.0 or some small thresholds

Optional: Before transferring the turtle or checking its position, you can do the return code by returning the round so that the exact numbers Give a picture.

  & gt; & Gt; & Gt; Round (40.01) 40.0  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -