How to Make a Clone Button and Instruction in MicroWorld EX

By Camille McCue

MicroWorld EX has a useful feature which allows you to make copies, or clones, of an object with five steps. The Clone button is used to clone the current turtle so that many copies can be made of it. Make a Clone button as follows:

  1. From the toolbar, click the Create a Button button. Then click the workspace anywhere.

    image0.jpg

  2. In the Button dialog box, fill in the following information:

    • Label: Type Clone in the Label field to name the button.

    • Instruction: Type clone who in the Instruction field. This command instructs the button to make a copy (clone) of the currently selected turtle (who), the turtle following instructions.

    • Do It: Select the Once radio button.

    • Visible: Leave this check box selected.

      After you fill in the information the dialog box should resemble the example.

      image1.jpg

  3. Click OK to close the Button dialog box.

    The Clone button is added to the workspace.

  4. Drag the button to reposition it to where you want it located.

    For example, position this button below the Initialize button in the upper-left corner of the workspace.

  5. Click the Clone button several times to make as many turtles as you want.

    Every cloned turtle has the same OnTouching and OnColor commands you added to the first turtle. Newly cloned turtles will appear on top of existing turtles. Click the Initialize button to scatter the turtles.

Although the concept is slightly different in each programming language, cloning is a common coding process. For example, in Game Salad, you create instances (copies) of a prototype, and each instance has the same appearance and information as the prototype. In Java, the concept of inheritance is somewhat similar. Objects inherit traits from the parent, but may be altered to behave in a slightly different way if needed.

This ability to make object-specific alterations also exists in MicroWorlds EX. For example, say that you have an airplane turtle that runs a project-wide procedure called fly. If you clone that airplane turtle several times, all the clones possess the procedure fly.

But if you want one airplane turtle to run a different fly procedure — maybe a kamikaze-style of flight — you can write a new fly procedure and place it in the backpack of that turtle. A local procedure of the same name will override the project-wide procedure.

Using cloning and related processes with a programming language allows you to reuse work you’ve invested in a project, especially when you need to create identical objects or procedures that vary slightly.