|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| 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.
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.
|
|||||||||||||||||||||||||||||||||||||
|