Goal: The ants react to colors.
Vocabulary: ask, launch, showtext, hidetext, wait
forever [t1, fd speed / 10 seth direction
t2, towards "t1 fd 1 / 20 * distance "t1
t3, towards "t2 fd 1 / 20 * distance "t2
t4, towards "t3 fd 1 / 20 * distance "t3]
compass, setpos [-195 -79]
fd 43 bk 43
ask [text2 text3 text4 text5] [launch [showtext wait 3 hidetext]]
In this project, the ants will react when they bump into a different color at the edges of the project page and when they pass over "sugar" on the grass.
- Create five additional text boxes. In text6 write "yum" and in the others write "ouch." Drag text6 near the sugar and drag each of the others near an edge. Make all of the text boxes transparent and invisible. (Place the eye tool on each, check transparent, and uncheck visible.)
- Right-click/ctrl-click on the color white to open its dialog box. Next to turtle write:
text6, showtext wait 1 hidetext.
This will make the word "yum" appear briefly as each ant passes over the "sugar." Wait 1 means, "Wait one-tenth of a second." The ants pause for this time, so it seems as if they are slowing down to enjoy the sugar.
- Make a green border around the "yard." If your yard has a color in the 60's, such as 65, then your border should have a color in the 50's. When we program a color, it affects all shades of that color. If we try to program color 55, it affects 50 - 59. So the yard cannot be in the same range of colors as the border.
- Open the dialog box for the border green and write "ouch" to activate the ouch procedure whenever an ant touches a border.
- In the ouch procedure, ask [text2 text3 text4 text5] tells those four text boxes to do whatever is in the next set of brackets.
Launch means, "Start doing this, and let all the other action continue at the same time." This way, the ants will keep moving without pausing when they touch a border. We can have the four "ouch" text boxes appear for a longer time without slowing down the action.
What happens if you change the amount of time to wait in the instruction for the white color?
What happens if you change the amount of time to wait in the ouch
Add more text boxes saying "ouch" and place them around the edges of the yard, then adjust the ouch
procedure so that all of them will show when a border is touched.
Add more ants to follow your first four.
Record sounds so that a voice says "yum" or "ouch!" when each color is touched. (Include the name of the sound in the programming for each color.)
On Your Own - Project Ideas
Make a background with areas of different colors. Program each color to make something happen when the turtles pass over it, such as: play a sound effect, play a tune, make a text box appear briefly, change the turtles' direction, make the turtles change size (with setsize
) or shape (with setsh