In this activity we continue working with the traceSquare function by calling it two times in order to draw two squares. One thing to note: You might be wondering why not use the drivexyTo command to move the robot in between drawing the two squares. The traceSquare code assumes that the robot is facing to the right (positive x direction) when the function is called. It then draws the bottom side, right side, top side, and left side of the square in order. So that's why it's best to use a driveDistance command moving vertically, a turnRight command, and then a driveDistance command moving horizontally to reach the second square's starting position. (In Lesson 8.5 we will learn how to modify the code so as to use the drivexyTo command in this situation.)
|
Grid Size: S M L | Simple View: | MinView: |
|
Coord: x-axis y-axis | Grid Lines: x-axis y-axis | |||
Grid: | 12x12 inches | 24x24 inches | 36x36 inches | |
72x72 inches | 96x96 inches | 192x192 inches | ||
1x1 inches | 2x2 inches | Fraction: | ||
xy-Range: | ||||
|
||||
|
||||
Quad: | 1 Quadrant | 4 Quadrants | 1&4 Quadrants | |
Units: | US Customary | Metric | Ruler: |
Labels: |
|
|
|
Font
px
|
|
Tics Lines: |
|
Width
px
|
Hash Lines: |
|
Width
px
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
|
Add code to the pre-placed code so that after the first square is traced, the code uses turnRight and driveDistance commands to move the robot to the point x = 19, y = 21 and then calls the traceSquare function to trace out a square with side length = 8 and bottom left corner at x = 19, y = 21. |
|
|
|||||||||||
|
|||||||||||