26.The Turtle Borders
So far we have seen that when the drawing area for the turtle ends the turtle will appear from the other side .. so if we are going upward then the turtle will appear from the button if we are off the limit on the right we will appear from the left. Now let's do a simple program that demonstrates it
Let's write a program that clean the screen go forward 450 then turn right 90 .. wait for 100 and then goes forward 500
The turtle default border definition is wrap that means that If the turtle moves off the edge of the screen it will continue on the other side. We can also explicitily order the turtle to use this mode ( in case we change the mode and want to go back to wrap mode ).
Let's write a program that clean the screen choosing the wrap mode go forward 450 then turn right 90 .. wait for 100 and then goes forward 500
The turtle can move past the edges of the screen, unbounded. In this case the turtle will not come back from the other side but will continue to move out of the drawing area
Let's observe the turtle behavior with the window mode. We will clean the screen choosing the window mode go forward 450 then turn right 90 .. wait for 100 and then go forward 300 turn right 90 wait for 100 and go forward 300
In this step.. when the turtle is out of the window area. we will get his location and print it on the screen
Will write the following commands cs window fd 450 rt 90 wait 100 fd 300 make "x xcor make "y ycor type [x is ] print :x type [y is ] print :y rt 90 wait 100 fd 300
If the turtle attempts to move past the edge of the screen it will stop. in this step we will go forward 30 times .. 10 point each time .. till we hit the border
Write the following clean the screen then fence mode .. then we will repeat 30 times [ fd 10 wait 10]
We have 3 different border conditions: wrap, window and fence. Each one of them behaves differently when the turtle is trying to get out of the drawing area borders.
Try to run a program with wrap, window and fence