Project Folders
Teacher Resources
Student Resources
How Do I?
Site Map
Our Team

race cars 1 2 3 4 5 6
Race Cars 6
6 KB

Goal:   The cars will stop after one car runs 30 laps.


Vocabulary:   if, bk (back), announce

Project Map



We need to add more instructions to the yellow and red colors.   It will be easier if we write a procedure for each color.   We'll call these procedures redcar and yellowcar.  

  1. Change the red instruction to just one word: redcar.  

  2. Change the yellow instruction to just one word: yellowcar.  

    Now when a car passes over its color, it will follow that procedure.

  3. In the redcar and yellowcar procedures, instead of wait random 50, change the command to
    wait 10 + random 40.

    This way we are sure that each car will disappear for at least one second before reappearing.   It may still disappear for up to five seconds.

  4. If red_lap = 30 means, "If the number in the red_lap text box is 30, do what is in the next set of brackets.   If it is not 30, ignore what is in the brackets."   So the car will keep racing until the text box reaches 30.

  5. The first command inside the brackets is bk 50.   That moves the car back a bit so that it appears to be at the finish line instead of the starting line.

  6. Announce opens an alert box containing the message inside the brackets."   It will tell us which car wins.   Click OK to make the announcement go away.  

  7. Stopall makes sure that both cars stop running, since the race is over when one car completes 30 laps.

  8. The yellowcar procedure works the same way for the yellow car, every time it passes the yellow starting line.

What If?
Try writing different announcements for the finish of the race.

Can you add a third car into the race? Remember to program the car, add another racing lane, and give the lane a starting line with a programmed color.

On Your Own - Project Ideas
Can you make something else happen when the race is over?
(Maybe you can record the sound of a crowd cheering after the announcement.)

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