Basics of Code Universal Color Conditionals in MicroWorld EX
The term universal color conditional in MicroWorld EX is a fancy way to say, “If anything touches a certain color, this is the result.” In a Mini Golf coding example, you want anything that touches the blue water trap to fall in. You will code the blue of the water trap to execute a procedure called watertrap when a turtle touches it. Then you write the watertrap procedure.
In this golf themed example the water trap portion of the course is used to demonstrate the concept of universal color conditionals. Create the universal color conditional for the water trap as follows:
Right-click (Windows) or Ctrl-click (Mac) the blue water trap. From the pop-up menu, select Edit Sky. Note that if you chose a different shade of blue than this example, your pop-up menu may show Edit Turquoise, Edit Cyan, or Edit Blue.
The Instructions for Color dialog box appears and allows you to set the universal color conditional. Because this example uses the color Sky, the name of the dialog box is Instructions for Sky.
In the dialog box, fill in these options
Mouse: Leave the Mouse text box blank for this project. This option means that when the user clicks on the color, the associated instruction is executed.
Turtle: In the Turtle field, type watertrap. (You will write the watertrap procedure later in this project.)
Once: Select this radio button.
This means that when a turtle is on the color sky, the watertrap procedure is executed once.
If you select the Each Time radio button in the dialog box, the turtle will execute the associated instruction with every step in the color until you move the turtle somewhere else.
Be careful with choosing Each Time because it can cause your turtle to get stuck. There are some instances when you will select Each Time, but usually, the preferred choice is Once. Once does not mean “one time ever”; it means, “one time until you exit the color and then return again later.”
Click OK to save your changes.
When a universal color conditional is coded, all locations on the background with that color possess the associated instruction. Be careful to look at the entire background to see where a color appears, and be especially careful of colors that appear in patterned backgrounds. If a turtle touches any instance of that color, the associated instruction is executed.