Goal: Count the laps while two cars race at random speeds.

Notes In this project, we use two text boxes to keep track of how many laps each car completes as they race. We count laps as each car passes over a different color.
- Create two text boxes and name them for your cars. Make sure to use one-word names.
- In the reset procedure, setred_car 0 means, "Set the contents of the text box named red_car to 0." Of course, setyellow_car 0 means, "Set the contents of the text box named yellow_car to 0." Be sure to use the names of your own text boxes in the reset procedure.
- Draw a starting line for each car to match its color. Then program each of these colors (right-click/ctrl-click to open the color's dialog box and write an instruction next to turtle).
For the red car, write:
setred_car red_car + 1
which means, "Add 1 to the number already in the red_car text box."
For the yellow car, write:
setyellow_car yellow_car + 1
Now every time a car passes its own starting line, its lap box will increase by 1.
If you let the cars race for many laps, you can see if one car has run more laps than the other.
What If?
What happens if you set one of the color's instructions to each time instead of once?
Challenge
Can you find a way to make more of a difference in the speeds of the two cars?
|