Académique Documents
Professionnel Documents
Culture Documents
ISBN 2-89371-493-5
Printed 4-00
Preface ....................................................................................... v
T I P S
1. Changing the Shape of a Turtle ....................................................... 1
2. Will Murray the Turtle Please Step Forward?................................ 3
3. Cloning a Turtle ............................................................................... 4
4. Graphics Galore ................................................................................ 5
5. Wordy Pictures ................................................................................. 7
6. Special Effects................................................................................... 8
7. Where Should I Click?...................................................................... 10
8. Averting Disaster.............................................................................. 12
9. Don’t Stop Me Now! ........................................................................ 14
10. Extra Pages are Your Friends........................................................... 16
11. Going Public on the Web.................................................................. 17
12. Link Up Your Project ....................................................................... 21
13. What Do Turtles Own? ................................................................... 22
14. All Together Now............................................................................. 24
15. Adding Interactivity to Your Projects.............................................. 27
16. Getting Your Messages into Shape ................................................. 30
17. Carefully Building a Simple Calculator .......................................... 31
18. Follow the Yellow Brick Road.......................................................... 33
19. When Turtles Collide ....................................................................... 36
20. Turn Your Pages .............................................................................. 38
21. Changing Your Mind ....................................................................... 40
22. Text Box Magic................................................................................. 42
iii
Preface
I
T SEEMS LIKE THE MORE YOU KNOW MICROWORLDS, the
more you want to know about MicroWorlds. Here is a book
of “secrets” that will help you learn the ins and outs of
MicroWorlds painlessly. We suggest that you read all the tips,
trying them out as you go on the computer. Even if a tip may not
seem relevant at the moment, you never know when it will come
in handy.
The tips in this book are not exhaustive. We picked some tips
which people have often asked us about, and others that are not
easily apparent in the software and documentation. The Tips
book does not replace the online Help Topics and Vocabulary. You
should check the Vocabulary to find the definition and example
of any primitive mentioned in this book. The Help topics provides
in-depth information about MicroWorlds features or concepts.
Please let us know if you like these tips, and if you have tips of
your own. You can check our web site www.LCSI.ca for sample
projects, and e-mail us at info@LCSI.ca.
v
This manual is for use with both the Windows and
Macintosh versions of MicroWorlds Pro.
1
Changing
the Shape
of a
Turtle
T
URTLES ARE ACTORS on the MicroWorlds stage. You can
have as big a cast as you like and your actors may wear
all sorts of costumes. In MicroWorlds, these costumes
are called shapes. You can design a shape and put it on the tur-
tle or you can import a picture as a shape.
WHEN
DISCUSSION
the turtle!
QUESTION: What if you want the bird turtle to fly in another
direction?
ANSWER: Hold down the Shift key key , click on the
2
Will Murray
the Turtle
Please Step
Forward?
D
ID YOU EVER WONDER why one turtle is in front of
another ? Did you ever want the car to drive in front of
the tree and didn’t know how to get it to do so ?
WHEN
DISCUSSION
3
Cloning
a Turtle
S
OMETIMES YOU NEED MORE than one turtle to wear the
same costume, have the same heading and run the same
instruction. You can easily clone turtles to accomplish this.
WHEN
DISCUSSION
4
Graphics
Galore
A
NY FUNNY PICTURE of your favorite cartoon character
or beautiful photographic image that you can get into
your computer can be used as a turtle costume.
WHEN
DISCUSSION
EXTENSIONS
5
Wordy
Pictures
W
ORDS CAN BE PART of your picture with a click
of the mouse !
WHEN
DISCUSSION
Text boxes are great for labeling screen graphics.
However, you may end up with many text boxes that can
be moved around if you do not freeze them.
If you wish to label a graphic and that label will not
change, consider stamping the text and removing the actual
text box. Here’s how:
1. Create a text box.
2. Type the label text. Be sure that the font, size, color,
and content is just what you want.
3. Right-click Control-click on the text box and choose Trans-
parent.
4. Choose the Stamper tool to stamp the text on the screen.
5. Right-click Control-click on the text and choose Cut to
6
Special
Effects
A
RE YOU WONDERING how to jazz up your project ?
Do you like flashy special effects ?
WHEN
DISCUSSION
EXTENSIONS
7
Where
Should I
Click?
T
HERE ARE THREE DIFFERENT WAYS to click the mouse on
the MicroWorlds page and have procedures run.
Colors, buttons, and turtles may contain instructions
for what to do when a mouse is clicked on them. (Sounds,
melodies, music, and videos are clickable if visible, but do not
run procedures.)
WHEN
DISCUSSION
8
Averting
Disaster
I
T DOESN’T TAKE MANY EXPERIENCES losing your work due
to a computer crash or programmer error before you learn
your lesson. Computers do strange things sometimes and
your latest programming idea can wreak havoc on hours worth
of work. Developing a few good habits and work strategies can
reduce the frequency of disaster.
WHEN
DISCUSSION
12 TIP 8 AV E R T I N G D I S A S T E R
USE FREEZEBG
Freezebg allows you to protect a background from
unwanted changes. This is handy when the user is
encouraged to draw or paint on a page, but you want to
return the background to its previous state for the next
user. After a freezebg command is issued, a page may be
returned to that state by using cg, clean, or double-clicking
on the Eraser.
Example:
• Paint a picture on the page.
• Type freezebg in the Command Center.
• Draw with the turtle or paint tools on the page.
• Double-click on the Eraser in the Graphics Tab area.
Voila! The background is a good as new!
EXTENSIONS
AV E R T I N G D I S A S T E R TIP 8 13
T I P
9
Don’t
Stop Me
Now!
O
CCASIONALLY YOU WISH to keep a user from clicking
off a button (or turtle) before all of its instructions
have been executed.
WHEN
DISCUSSION
10
Extra Pages
are Your
Friends
T
HERE IS NO SUBSTITUTE for good design and visual litera-
cy, but sometimes the creative process can get messy.
Some hints may help you keep your project on track.
WHEN
DISCUSSION
11
Going
Public
on the Web
D
o you want to share your creations with the world ?
You can publish your project on the World Wide Web
and view it on a Browser anywhere in the world !
WHEN
DISCUSSION
Command Check
The following commands are not available for use in
projects posted on the Web. Do not use these in your Web
project procedures or instructions:
cc merge importtext
newprojectsize printtext openworksheet
saveproject placepicture closeworksheet
setfooter loadpict setcell only
savepict loadshape getcell
saveshape loadtext
savetext exporttext
Numbers, numbers
If you happen to use any decimal numbers as text in your
project, create them as “executable” numbers instead. For
example, if you need to have the number 3.1 as text (not
stamped as graphics), then type it as 31 / 10 instead. This is
because decimal separators differ from country to country.
12
Link Up
Your
Project
Y
OUR PROJECT LINKS are no longer limited to a computer.
You can make connections with the Web and your
friends on the Internet !
WHEN
DISCUSSION
13
What
Do Turtles
Own?
M
ICROWORLDS TURTLES can remember a number of
things. These are called state variables. This enhances
their intelligence and makes it easier to get turtles to
do tricky things without your needing to keep track of too many
variables.
WHEN
DISCUSSION
22 TIP 13 W H AT D O T U R T L E S O W N ?
Like built-in state variables, turtlesown creates a
reporter and a corresponding command beginning with
set.
There are three actions associated with turtlesown:
• Telling MicroWorlds to give a state variable to every
turtle in the project.
• Assigning a value to that state variable.
• Using that state variable in some way.
Let’s try an example.
1. Start a new project.
2. Hatch some turtles so that three turtles appear on the
page.
3. Change their shapes so that you can tell them apart:
t1, setsh "car
t2, setsh "plane
t3, setsh "boat
4. Tell MicroWorlds to give every turtle the state variable,
homepos:
turtlesown "homepos
5. Set the turtles to their “home” positions:
everyone [sethomepos pos]
6. Move the turtles to different parts of the page and then
set them back to their “homes”:
everyone [setpos homepos]
The best thing about turtlesown is that the state of each
variable is stored with the project upon saving. This
allows you to use these values at a later time.
W H AT D O T U R T L E S O W N ? TIP 13 23
T I P
14
All
Together
Now
Y
OU WOULD BE SURPRISED by how often you can give
every turtle on a page the same instruction. With a bit
of planning and problem solving, you can reduce your
programming workload by using the everyone command.
WHEN
DISCUSSION
EXTENSIONS
15
Adding
Interactivity
to Your
Projects
Y
OU HAVE ALREADY LEARNED how turtles and buttons
may be used to add interactivity to a project. Sliders
and dialog boxes add other forms of interactivity to
MicroWorlds projects.
WHEN
DISCUSSION
SLIDERS
Try this:
1. Hatch a turtle.
2. Give it the instruction fd velocity – gravity set to
Many Times.
3. Create a slider by clicking on the Slider tool and then
on the page.
4. Name the slider velocity. Give it a range of 0 for
minimum and 99 for maximum.
ANNOUNCE
Announce is used to display a pop-up dialog box containing
some text on the screen. It requires the user to click OK
before it disappears and allows the program to continue.
Therefore it really commands attention. Announce takes
one input of a word or list and displays that data on the
screen. Announce commonly precedes the sentence
reporter, which assembles words and lists into one input
to be displayed by announce.
Try the following:
announce [You win!]
announce 5 * 4
announce heading
announce heading * 5 * 4
announce (sentence who [wins the race!] "by 1 +
random 10 "lengths)
QUESTION
Question displays a dialog box, but this time asks the
user to input some sort of answer. The thing entered by
the user, even if nothing is entered and OK is pressed, is
stored in a special reporter called answer. Answer holds
that data until another question is asked or you quit
MicroWorlds. Sentence may prove helpful if variables
and literal text need to be combined in the question.
16
Getting
Your
Messages
into Shape
D
ID YOU EVER WONDER if you could shape the messages
produced by the question and announce commands ?
This trick allows you to make the information appear in
the form you wish.
WHEN
DISCUSSION
17
Carefully
Building
a Simple
Calculator
T
HE FUN THING about text boxes is that while displaying
information, this data can also be automatically reported
in your program.
WHEN
DISCUSSION
C A R E F U L LY B U I L D I N G A S I M P L E C A L C U L AT O R TIP 17 31
EXTENSIONS
32 TIP 17 C A R E F U L LY B U I L D I N G A S I M P L E C A L C U L AT O R
T I P
18
Follow
the Yellow
Brick Road
S
OMETIMES YOU NEED A TURTLE to follow an irregular
path. You could use brute force to tell the turtle how to
move precisely by programming an endless series of fd,
bk, rt, and It commands. Or...
WHEN
DISCUSSION
Turtles know where they are and which way they are
facing. Pos and heading are reporters assigned to turtles.
The command, towards, turns the current turtle towards
a specified turtle. Distance is a reporter that tells us the
distance between one turtle and another.
t1, towards "t2
tells the turtle, t1, to face t2.
t1, show distance "t2
shows the number of turtle steps between t1 and t2.
Say you want your turtle to run around an irregular track.
A clever way of controlling the turtle’s motion is to
“drop” a series of other turtles strategically around the
track. You may then use towards and distance to follow
the path.
19
When
Turtles
Collide
I
N SOME SITUATIONS, you can program a color to cause an
action when a turtle hits that color. This works fine for hitting
standing targets, but sometimes you want to know if a
turtle actually collides with another turtle. MicroWorlds uses
the touching ? reporter to check for such collisions.
WHEN
Most video games require that you know when one moving
object collides with another. Science simulations may also
use collision detection.
DISCUSSION
EXTENSIONS
20
Turn
Your Pages
M
OST SOFTWARE APPLICATIONS with multiple screens
have a way of navigating between screens by clicking
on buttons. Often these buttons have arrows as icons
indicating previous or next screen.
WHEN
DISCUSSION
38 TIP 20 T U R N Y O U R PA G E S
For example:
to previous
if (first pagelist) = "page2 [page1 stop]
if (first pagelist) = "page3 [page2]
end
to next
if (first pagelist) = "page1 [page2 stop]
if (first pagelist) = "page2 [page3]
end
The procedures in the square brackets are the names of
the pages you wish to turn to. Note the use of stop in the
first line of each procedure. This stops the procedure from
continuing provided that the if statement is true.
Otherwise, clicking the next button on Page1 may turn to
Page3.
T U R N Y O U R PA G E S TIP 20 39
T I P
21
Changing
Your Mind
B
UTTONS CAN BE LIKE CHAMELEONS, changing their
instructions magically via Logo programming.
WHEN
DISCUSSION
its name. You can also find the button’s name by clicking
the Eye tool on it.
Next, you need to decide if the button’s action should
launch Once or run forever (Many Times). The commands,
launch and forever, are necessary in programming a
button’s instruction.
Get is a primitive that reports the state of screen objects.
Set is a command that can change the different states. See
the online help for more detailed information about get
and set.
22
Text Box
Magic
T
HE WORDS IN A TEXT BOX can make things happen !
Using the “magic” command onreadline, your text box
can act like the Command Center.
WHEN
DISCUSSION
Create a text box named Text1. To make your text box act
like a Command Center, type (in the Command Center):
onreadline "text1 "run
The first input is the name of the text box and the second
input is the instruction to run. In this case, run runs its
input as a Logo instruction. Hatch a turtle, then try
typing a command such as forward 50 in the text box
now. It moves the turtle forward!
To turn off this feature, make the second input to
onreadline empty.
onreadline "text1 "