Project 550: Racing Road

8. Design and program scrolling obstacles

Design a sprite that will slow your car down later. The obstacle should scroll downwards based off your "speed" variable.
Starting point file for this challenge

Your goal

Steps

1. Design an obstacle sprite

You can either pick a new sprite by clicking on the blue cat button, or design one again.

2. Set the obstacle sprite's starting position

Click and drag the new sprite into the top left of your screen. 

Then, add a "when green flag clicked" block into the code. 

Finally, add a "go to x: __ y:__" block with the new coordinates of your sprite. 

3. Copy over the cloning code

Go back into your road divider line sprite, and find the code that tells it to clone itself. Click and drag this code over your new obstacle sprite, and let go when you see the boost sprite wiggle. 

Your code should now be copied into the obstacle sprite. 

4. Copy over the scrolling code

Repeat the last step, but this time for the code that tells the clones to scroll downwards. 

5. Make the clones more rarely and more randomly

The game would be way too hard if the obstacles appeared as often as the road lines did! And too predictable. 

Grab an "operators" block called "pick random __ to __" and put it in the "wait __ seconds" blank. Try any range you like, but the example uses 1 to 5 seconds. 

6. Duplicate the sprite for the other side of the road

Right click on the boost sprite and select "duplicate." Click and drag the new sprite to the top right of your screen, and change its starting coordinates accordingly.