Note that there are some explanatory texts on larger screens.

plurals
  1. POStopping a turtle when it reaches a point, Python
    primarykey
    data
    text
    <p>I am currently in a beginning programming class, and I am blowing through the assignments. Right now, I have to make 3 houses with the module turtle (which I accomplished): </p> <pre><code>def drawBody(mover): #Rectangle part mover.fillcolor("blue") mover.begin_fill() for i in range(2): mover.forward(100) mover.right(90) mover.forward(75) mover.right(90) mover.end_fill() #Triangle part mover.fillcolor("red") mover.begin_fill() mover.left(45) for i in range(2): mover.forward(70.5) mover.right(90) mover.right(45) mover.forward(100) mover.end_fill() #Create preproduction turtle import turtle wn = turtle.Screen() josh = turtle.Turtle() pointGoTo = -175 for houses in range(3): josh.penup() josh.goto(pointGoTo,0) josh.pendown() drawBody(josh) josh.right(180) pointGoTo = pointGoTo + 125 wn.exitonclick() </code></pre> <p>here is the while code. So I want the turtle to stop at a certain point, The top left corner of the red square. I have tried multiple points but the while just doesnt break/stop. Is my syntax off? or am I approaching this whole line of the house thing all wrong? If i am being vague, please ask what you dont understand, I really want to figure this out, but i am all out of ideas.:</p> <pre><code>def drawBody(mover): #Rectangle part mover.fillcolor("blue") mover.begin_fill() for i in range(2): mover.forward(100) mover.right(90) mover.forward(75) mover.right(90) mover.end_fill() #Triangle part mover.fillcolor("red") mover.begin_fill() mover.left(45) for i in range(2): mover.forward(70.5) mover.right(90) mover.right(45) mover.forward(100) mover.end_fill() mover.left(90) mover.forward(75) mover.left(90) n = mover.position() print(n) while True: mover.forward(100) n = mover.position() print(n) mover.left(90) mover.forward(5) mover.left(90) n = mover.position() print(n) mover.forward(100) mover.right(90) mover.forward(5) mover.right(90) if n == (-75.30,0.00): break #Create preproduction turtle import turtle wn = turtle.Screen() josh = turtle.Turtle() pointGoTo = -175 for houses in range(3): josh.penup() josh.goto(pointGoTo,0) josh.pendown() drawBody(josh) josh.right(180) pointGoTo = pointGoTo + 125 wn.exitonclick() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload