Project 196: Dodgy Road

5. Increasing Level and Difficulty

Now that we have enemy collisions handled, let's use what we have learned to increase levels.
Starting point file for this challenge

Your goal

Steps

1. Detecting a finished Level

We will add another condition by adding another "when green flag clicked" and "forever loop" and "if then" block. This time the condition will be touching the goal.  

2. Increase the level variable when a level is completed

Change the condition like last time from "mouse-pointer" to "goal" When we hit the goal the level should go up by 1.  We can use a "change _____ by 1" block to do this.  Be careful to set it to the right variable. 

3. Return to the Start

Let's include a "go to x: 0 y: -150" block below the "change level by 1" block. 

4. Using a Nested If Statement

Let's adjust our goal collision code to increase the difficulty if the level is less than 20.  To do this we will add another "if then" block inside of the collision code for the goal.  This is called a Nested If Statement.   For our condition we can grab a  " blank < 50" block from operators tab and adjust it to be "level" < 20.  

5. Test if the Level is Less Than 20

Now the new condition will just be that the level is less than 20.  Change 50 to 20, and drag in the level block from the Variables Tab.  

6. Make the Game Harder

Inside the new if statement, let's decrease the frequency by subtracting 0.05.  We'll use a "change frequency by  -0.05" block for that. This will make enemies appear faster.