Introduction
There are extended commands in Little Turtle for older students.
The XY and/or Bearing commands are for students that are learning about coordinate systems, angles, ...
- Bearing command
- XY command
- Circle command
Enable the Extended Commands
The extended commands are disabled in Little Turtle. There are two ways to enable them.
1. To permanently enable them, modify the code in turtle.js. Change the following flags (variables).allowXYs → true
allowCircles → true
allowBearings → trueTo disable the Left/Right and Move commands
allowMoves → false
allowDirections → false2. To temporarily enable the commands, add one or more parameters to the URL.
http://server/turtle.html?xy&bearing&circle Note: This does not disable any of the other commands.Bearing Command
The bearing command is a replacement for the Left/Right commands. It sets the direction the sprite is pointed. It is used with the move command to move the sprite in a specific direction.
In Little Turtle, a bearing is a clockwise angle measured from a ray pointing directly up.
Note: Technically it is not a bearing; its an azimuth. I call it a bearing anyway.
Command Example
B 128 Bearing Angle (Direction)
XY Command
The XY commands moves the sprite to the X,Y coordinates. It is a combination of (replacement for) the Left/Right/Move/Bearing commands.
Note:
- coordinates are pixels (integers) - If the pen is down a line will be drawn from the original position to the new position. - The command does not change the direction the sprite's is pointing.
- It might be best to not display the sprite when executing XY commands. The direction the sprint is pointing could be confusing.Command Example
XY 100 100 Coordinate System
Circle Command
The circle command draws a complete or half circle.
- The center of the circle is the current position of the sprite.
- The radius of the circle is in pixels (integer).
- The radius must be greater than 0.
- The half circle's flat side is at right angles to the current sprite direction.
- The half circle is drawn in the current sprite direction.
- The line size and color is determined by the current pen settings.
Note: The pen must be down for the circle to be visible. No error is generated if the pen is up.
Command Example
CF 30 <- draw full circle of radius 30 pixels
CH 25 <- draw half circle of radius 25 pixelsDrawing Example