3. Turtle world
In this lesson we will meet the turtle's environment. What ,exactly, is the turtle "environment"? Well the turtle lives in the drawing box area and he can not leave that area . So the drawing box area is the environment :). We will learn exactly on which position inside the drawing box the turtle is located at a given moment. And we will help him to get to some other positions inside his environment. Lets start by cleaning the screen
Use shortcut command
The turtle world is made of an x-axis and y-axis, where the x-axis is taken to be horizontal and the y-axis is taken to be vertical. When starting a program the turtle will stand on the (0,0) point. This means the horizontal value (x) is 0 and the vertical value(y) is 0. If we will tell the turtle to move fd 50 the turtle will stand on the point (0,50). Move forward 50 points
After the previous step the turtle is standing now on the (0,50) point . We have learned before how to clean the screen using the cs command. Notice that after cleaning the screen the turtle will return to the (0,0) point. Please clear the screen
Now that we are standing at the (0,0) point what will we have to do in order to get to (50,0) point? Yes we will have to turn right and then go forward. By doing this the turtle remians on the same point on the y-axis while his point on the x-axis has changed. Please move the turtle to (50,0) point
turn right in a right angle and then move forward
rt 90 fd 50
We already saw that the (0,0) point is the center of the turtle's world. If we want to get the center point without cleaning the screen we can use the home command. Notice the turtle will draw a line showing how he went back home. If we want to prevent this line we can tell the turtle to lift the pen up (penup) and then go home and put the pen down. Move the turtle to the point (0,0) using the home command.
We can also use a Logo command in order to set the turtle's x and y coordinates. The commands are setx NUMBER and sety NUMBER respectively , where NUMBER can be any numeral. Please set the x coordinate to 100
We already saw how we can use the setx and sety commands. We can combine these into one command using setxy NUMBER-X NUMBER-Y Clear the screen and set the turtle to the (50,50) point.
Clear the screen first and then setxy
cs setxy 50 50
If you imagine the small tip of the turtle triangle is his head, we can know in which direction he is heading. We can also command the turtle to face in any absolute direction based on the 360 degrees of a circle. Note that when we command the turtle to turn rt 90 we are moving the turtle head 90 degrees clockwise. Commanding the turtle to turn left 90 moves its head 90 degrees counterclockwise. If we want the head to point in the direction of a specific absolute angle, we should use the command setheading NUMBER (shortcut: seth NUMBER), where NUMBER is the number between 0-360 representing the angle direction in which we want our turtle head to point. To see how this works, first type rt 45 followed by rt 90. Next, type seth 45 and seth 90 to see the difference. Now, turn the turtle head to an absolute 175 degrees.
Use heading command
The command for creating an arc is : arc ANGLE RADIUS,ANGLE is a number between 0-360 representing the angle that will be covered the turtle rotates his position.RADIUS is the distance of the arc from the turtle’s head. Set an arc with an ANGLE of 90 and a RADIUS of 60 from the turtle's head
arc 90 60
Now we can use the arc command to create a circle. Create a circle with a radius of 100.
Circle is like an arc with a 360 degree angle
arc 360 100