Project 114: Ant Racing

8. Send the racers back to the start if they leave the race track

Make it so that if a racer goes out of bounds, it gets sent back to the start
Starting point file for this challenge

Your goal

Steps

1. Add an if-statement

We want our code to check if our racer is touch outside of the race track, so we need to use an if-statement. You can find the "if __ then"-statement in the orange "control" section. 

2. Add a "touching color __" block

In order figure out when the racers leave the track, we are going to check if they are touching the color we have chosen as a background to our track. This is why it is important to make your background a solid color, otherwise this condition wouldn't be able to check all colors in a multi-colored background.

3. Select the background color for your "touching color __" block

Click on the colored circle inside your "touching color __" block and use the button at the bottom of the color picker to select your background color from the preview window.

4. Inside the if-statement, send the racer back to it's starting position and rotation

Use the same movement blocks you used to set your racer's starting position and rotation.

5. Repeat your code with a forever loop

We don't want the motion to just happen once – we want it to repeat. To repeat code, we need to add a loop. Add a forever loop to keep the game checking. You can find the forever loop in the orange "control" section.