Table of Contents | Previous Page | Next Page
Copyright Don Sleeth, 1998 ©

Page 6 - Play time

Load in your work

From the file menu, open your project named Page5. Then from the file menu select "Save Project As..." and save your project as Page6

In the procedures page, your program should look like this

	
====================
to Main
    cc
    talkto "t1
    repeat 20 [Square]
end
====================

to Square
    forward 50 right 90 wait 1
    forward 50 right 90 wait 1
    forward 50 right 90 wait 1
    forward 50 right 90 wait 1
end

to Start
    Main
end
	

Play with your creation

Try experimenting with your program. In the Shape Center, click on a shape and then on the turtle. Click on the Start Button. It doesn't matter what shape the turtle is wearing, he still goes around and around in a square. Notice that although the turtles head rotates with the direction it is travelling, the shape does not. Try adjusting the amount the turtle moves forward in the procedure Square. Try changing the size of the shape with the magnifying glass.

It would be nice if the turtle could be programmed to automatically change shapes. With MicroWorlds this is actually very easy. There is a built-in procedure called setsh which stands for Set Shape. It requires an input which is either a word (must be the name of a shape) or a list of words (must be a list of names of shapes). Here is an example of both:

setsh "Horse1
setsh [Horse1 Horse2 Horse3]
Why do I need to put the quotation in front of "Horse1? Why not just setsh horse1? When you give MicroWorlds Logo a word, like start or main or setsh or horse1, it assumes the word is a procedure to look up in its vocabulary and run. If we don't put the quotes in front of horse1 it will try to run the procedure horse1. Putting the quotes in front says "This is a name of something, don't try to run it."

Go to the Command Center and type horse1 and press Enter. See, it tries to 'run' horse1 but doesn't know how to. However, in the instruction setsh "horse1, because the word is quoted, MicroWorlds Logo knows that you mean the name of something, and treats it just as a word and not something it needs to do.

Setsh needs either a word or a list of words as its input. So, setsh "horse1 is a complete instruction. In the second example, setsh [Horse1 Horse2 Horse3] you don't have to quote each name because the brackets show that it is a list and setsh is known to accept as its input a list of names of shapes. Therefore MicroWorlds knows to interpret the words as a list of shape names.

Change your Main procedure to look like this:

	
to Main
     cc
     talkto "t1
     setsh [Horse1 Horse2 Horse3]
     repeat 20 [Square]
end
	
Go back to your program and try it. MicroWorlds Logo has a neat feature where if you set up a list of shapes ahead of time with setsh, as we did, each time the procedure forward or back is called, a new shape from the list is used. This makes animation particularly easy!

Can you think of a way to improve Square?

When we use the built-in procedure forward, we give it a number, an input that is a number, that tells it how far forward we want the turtle to go. The number of steps that the turtle takes each time varies, depending on the number we give to forward. The number is a variable. It would be nice if we could improve Square so that we could decide each time we use Square just how big a square the turtle should move in.

First we need to learn about Variables, then we will be able to make this improvement.

Save your work

So that you can continue with this project at another time, please save your work as Page6

Table of Contents | Previous Page | Next Page