Goal: Two cars race at different speeds.
To race two cars at different speeds:
- Hatch a second turtle and put a second car shape on it. Drag it so it is roughly lined up with the first car.
- Everyone means that we will be talking to each of the turtles in turn, no matter how many. Put the instruction list in brackets.
In the command center, type everyone [seth 90] to be sure that both cars will drive to the right.
- In the reset procedure, everyone [setx -225] lines up both cars at the same x coordinate. (You may choose a different number to fit your project size.)
- Place the eye tool on one turtle to open its backpack, and give it the OnClick rule fd 1. Set it to Forever.
- Place the eye tool on the other turtle and give it the OnClick rule fd 2. Set it to Forever.
Now when you click on a turtle, it will move forward over and over again.
- In the go! procedure, everyone [clickon] is like clicking on each of the turtles in turn very fast. This way, both cars can start the race, but they can each follow their own instruction.
What if each car moves forward by a different fraction,
such as fd 1 / 2 or fd 1 / 3?
Can you give each car a different starting position in the reset procedure so that they both reach the right edge of the project at the same time?
On Your Own - Project Ideas
Can you animate two or more shapes in another scene?