Step 10: Obstacles Code Cont’d

Goal:


We will now continue the obstacle spawn code.

This last portion will control the random spawning, the movement to the left, and adding a point to the player’s score if they pass through.

Steps:

    1. Click Motion and drag a got to x y block into the forever loop.
    2. Set the number in the x part of the go to x y to 2400.
    3. From Operators, place a pick random 1 to 10 block inside the y part of the go to x y block.
    4. Change 1 and 10 to -45 and 40 inside the pick random block.
    5. From Control, place a repeat until block inside the forever loop.
    6. From Operators, place a less than block inside the condition of the repeat until block.
    7. From Motion, place a x position block on the left side of the less than block and type -200 into the right side.
    8. From Motion, place a change x by 10 block into the repeat until block and change 10 to -5.
    9. Lastly, from Control, place a change highscore by 1 block after the repeat until block as the last block in the forever loop.

Code: