Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Vocabulary
MWForum
Site Map
Search
Our Team
How do I remove turtles with a command?
In some game projects, you might wish to hide or remove turtles one by one:

t1, ht   (to hide a turtle)

remove "t1   (to remove a turtle from the page)

everyone [remove who]   (to remove all turtles from the page… who is the current turtle)

Note:  When you remove turtles as a program is running, you need to have a way to restore the turtles if you wish to start the action all over again. See How do I hatch turtles under program control? The project below shows how to create a batch of turtles and remove them one by one as the game proceeds.

Right-click HERE to Download
Click go to set the turtles in motion. Click attack! and the snake will try to catch a turtle. How many tries does it take to catch all the turtles?

code
Note:  Do you really need to remove turtles or can you just hide them? Here is another version of the project which simply hides the turtles with ht. Since they are never removed, they never need to be hatched again. But be careful! The turtles will keep moving even if they are hidden. Be sure to stop all the action when the game is over. (stopall has been added to the allgone? procedure.) The startup procedure runs automatically when the project is launched and ensures that all turtles are in position.

code

The procedures go, attack!, and wiggle are the same as above.

This version hides turtles instead of removing them. The turtles each have the instruction, bye.

Right-click HERE to Download

« Previous
Menu
Next »


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