MicroWorlds EX™ Lessons

Lesson Five: Inside the Turtle's Backpack: "State" and "Rules"

Step 1: Opening a Turtle's Backpack

Each turtle that you hatch has its own backpack to store its own PRIVATE* shapes, procedures and rules. (* This means shapes, procedures and rules that apply to this particular turtle only.) To open any turtle's backpack, just right-click on the turtle itself and choose Open Backpack.

When you open a turtle's backpack, you will open a dialog box with 6 different tabs at the bottom of the backpack:
Shapes . . . . . . . State. . . . . . . . . Procedures
Audio. . . . . . . . Notes . . . . . . . . .
Rules. When you first open a turtle's backpack, it will open directly to the "State" tab. After that, it will open to whichever tab you were last viewing.

Step 2: The Turtle's Current "State"

As you see in the graphic at the right, you can find out a great deal about this turtle by looking at the info on the State page.

  • Using the Edit button, you can change the name of the turtle.
  • The turtle's current position on the screen is given by the Xcor: and Ycor: boxes (You could use Pos to find these out and SetPos [ # # ] to place a turtle in an exact spot.
  • Heading tells the turtle's current heading. Change this with the Setheading command ( seth # )
  • Size give the current size. The default size for all shapes is 40.
  • Animate lets you choose between Setshape and Setrotate as each iteration of the animation occurs.
  • Pen tells you if the Pen is Up or Down, or even in the Erase mode.
  • Visible? lets you know if the turtle has been hidden. Use ht (hideturtle) or st (showturtle) when you need to change this.

Step 3: This Turtle's Procedures

If you want to write any new commands for this turtle to follow, click on the Procedures tab at the bottom of the dialog box. Here you can type in any commands for THIS turtle only to follow. It will refer to shapes in its own backpack before considering "public" shapes. If any procedure name is duplicated in the common Procedures area for the project, a turtle will also give higher priority to that same command name in its backpack and only follow that private version of the procedure. For more on writing procedures, see the other lessons along the way.

 

Step 4: Creating "Rules" for This Turtle

Once you click on the Rules tab at the bottom of any turtle's backpack dialog box, you can create rules for a turtle to follow when faced with several possible conditions:

 

  • Using the OnClick area, you can type in a command or two that the turtle should follow once it has been clicked on with the mouse. (You may select this action to happen once or repeatedly using the Forever option.)
  • OnColor gives you an opportunity to insert a command that the turtle must follow once it moves onto a portion of the screen where one of the given colors is. (Pull down the arrow below OnColor to see the possible colors.) Again, you may choose Once or Each Time the turtle is on this color.
  • OnTick allows you to specify a repeated action that will occur again and again when a "tick" of the clock goes by. This is measured in tenths of a second, so 10 in this box would mean every 1 second.
  • OnTouching is used to issue a command when the turtle ends up touching another turtle. This is useful for making turns or collisions or decisions at certain times.
  • OnMessage is the command that tells this turtle what do do when it receives a certain message. (May be a set message or ANY broadcast message.)
  • When this....Do that lets you specify a given condition that needs to be met before some other contingent command or activity starts.

 

Lesson Six: Creating and Controlling Multiple Turtles

Main MicroWorlds EX Tips Page



HTS Home | Calendar | Classes | Departments | Resources | What's New? Newsletter
©2008 Holy Trinity School HTS HomeContact HTS