How to Test Primitives in MicroWorlds EX’s Command Center

By Camille McCue

There are two types of commands you can create in MicroWorlds EX: primitives and procedures. You can type any command, primitive, or procedure, at any time into the Command Center for the purpose of testing out the command. The Command Center is located just below the workspace, at the bottom of the MicroWorlds EX window.

  • Primitives: These are built-in commands that already exist in the MicroWorlds EX vocabulary.

  • Procedures: These are new commands you create by putting together primitives and other procedures you have already coded.

Here is what the Command Center looks like.

image0.jpg

Try out a few of these primitives at the Command Center:

  • Setbg: This command sets the background color. In the Command Center, type setbg “red and then press Enter (Windows) or Return (Mac). This command sets the background color to red in the example below.

    Now try setbg 15. The background is still red! That’s because MicroWorlds uses both names and numbers to represent colors. The color name red is the same as the color number 15.

    Try a few more color names such as yellow, green, and violet. Also test a few more color numbers using any number from 0 to 139. You can type a new line of code each time, or replace the color you typed previously and then press Enter/Return.

  • Setbg random: This command sets a random color for the background. In the Command Center, type setbg random 140 and then press Enter (Windows) or Return (Mac). This command sets the background color to a color number selected randomly from 0 to 139. Execute the command a few times to see many new colors appear.

  • Home: This command moves the turtle to the home position, which is the exact center of the workspace. To try out this command, drag the turtle to any location in the workspace. In the Command Center, type home and then press Enter (Windows) or Return (Mac). The turtle moves to the home position and points toward the top of the workspace.

  • Setc: This command sets the color of the turtle. In the Command Center, type setc “yellow and then press Enter (Windows) or Return (Mac). This command stands for set the turtle color to yellow. Try a few more colors such as pink, lime, cyan, and brown. The color of the turtle is the same as the color of its drawing pen.

  • Setc random: This command sets the turtle color to a random color. In the Command Center, type setc random 140and then press Enter (Windows) or Return (Mac).

    This command stands for set the turtle color to a color number selected randomly from 0 to 139. Execute the command a few times to see the turtle turn many different colors. The color of the turtle is the same as the color of its drawing pen.

  • Fd or bk: These commands move the turtle forward or backward. In the Command Center, type fd 10 and then press Enter (Windows) or Return (Mac). This translates to move forward 10 steps. Now type fd 100 and note the difference. Then type fd 1000 and see what happens when it moves off one side of the workspace! The maximum value for forward and backward is 9999.

    The opposite of moving forward is moving backward. Type bk 10 and then press Enter (Windows) or Return (Mac). This command translates to move backward 10 steps. Type some other distances and observe the change in the turtle’s position.

  • Pd or pu: These commands set the turtle’s pen down or up. In the Command Center, type pd and then press Enter (Windows) or Return (Mac). This translates to pen down. It looks as if nothing happens! That’s because the turtle pen is below the center of the turtle — when he’s not moving, you can’t see whether his pen is up or down.

    Try the forward and backward commands to see the turtle draw as it moves. The command pu stands for pen up, but don’t give the pen up command now; just leave the pen down.

  • Setpensize: This command sets the pen size. The pen size indicates the line width when the turtle moves with the pen down. The starting (or default) value is 1. Larger sizes make wider pen widths.

    In the Command Center, type setpensize 3and then press Enter (Windows) or Return (Mac). This sets the pen size to the value 3. Try several values to create pen sizes of different widths. You can see the effect of changing the pen size only when the pen is down and the turtle is moving.

  • Rt or lt: These commands turn the turtle right or left. In the Command Center, type rt 90 and then press Enter (Windows) or Return (Mac). This translates to turn right 90 degrees. Now type lt 90 and press Enter/Return. This translates to turn left 90 degrees. Try other degree angles such as 45, 180, 270, and 360.

    Turtle turns are always made from the viewpoint of the turtle. If the turtle is facing north and you give the command rt 90, the turtle faces east. If you give the command rt 90 again, the turtle faces south. Give the command rt 90 a third time and the turtle now faces west.

  • Clean: This command clears any graphics from the workspace. In the Command Center, type clean and then press Enter (Windows) or Return (Mac). Notice that the background color remains. The turtle also remains and does not change its position.