Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Vocabulary
MWForum
Site Map
Search
Our Team
How do I hatch turtles under program control?
In some game projects, you might wish to surprise the user by hatching an unknown number of turtles as the game is running. Use newturtle, word, setinstruction, (and more) as appropriate. See Ant Hill 6, a game similar to the guessing game below.

Right-click HERE to Download
Fill the jar with bouncing beans and guess how many there are. How many guesses do you need?

code
Notes:  

It can be easier to create a lot of new turtles all at once with this method than to hatch and modify turtles one by one, as you prepare a project. But remember that you can also hatch a batch of identical turtles quickly if you select, copy, and paste (many times) a programmed turtle or cluster of turtles.

Everyone [remove who] removes all existing turtles from the page.

The Ant Hill 6 project notes explain one way to hatch and activate multiple new turtles. The hatchturtles procedure above is similar but it uses dotimes as an alternate to repeat and uses make instead of a hidden textbox to hold the value of howmany.

MicroWorlds cannot launch an unlimited number of processes. It can run at most 34 simultaneous processes. So if you animate the new turtles, you must limit their number to a maximum of 34. If you do not activate turtle instructions, you may hatch many more turtles (up to 150, if there are no other objects on the page). See the variation below.

code

(The guess procedure is the same as above. There is no need for a bounce procedure.)

These beans don't bounce around, so we can hatch a lot more. Guess how many?

Right-click HERE to Download

But if you are not going to animate your turtles, do you really need to hatch so many of them? The variation below uses just one turtle to stamp as many beans as you wish. When creating such a project, just remember to freeze the background with freezebg before you begin stamping so that you can erase just the stamped objects with clean, between each round of a game.

code

(The guess procedure is the same as above.)

This version uses just one turtle! (Don't hatch a lot of turtles unless you really need to!)

Right-click HERE to Download

« Previous
Menu
Next »


© copyright 2001 - 2012  OpenWorld Learning.   All rights reserved.