Home
Project Folders
Teacher Resources
Student Resources
En ESPAÑOL
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

race cars 1 2 3 4 5 6
Race Cars 4
Screenshot
Turtle Face Get Web Player
  if you cannot see the project


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




Code
Shapes
Project Map

code


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.

  1. Create two text boxes and name them for your cars.   Make sure to use one-word names.  

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

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




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