Time for action - count the levels

We'll add our levels to the stage:

  1. With the stage selected, create a new variable called Level.
  2. From the Variables palette, add the set to block between the reset timer and the forever blocks. Select Level from the drop-down list.
  3. Change the value of the set level block to 1.
    Time for action - count the levels
  4. Now, we need to increment the level when the second ball enters the stage. Select ball2 from the sprites list.
  5. Add the change Level by 1 block between the wait until timer > 30 and the show blocks.
    Time for action - count the levels
  6. Right-click on the timer block on the stage and select hide. We don't need to see the timer anymore.
  7. Play the game and after 30 seconds, the Level increases by one.

What just happened?

We built the visual representation of the levels based on the programming we previously created. The level changed when we introduced the second ball, which happened after 30 seconds of game play.

Level two is currently infinite.

Have a go hero

What ideas do you have for creating levels? How about if you increase the ball speed for each additional level? For each ball, you need to adjust the number of steps the sprite moves when it bounces off the edge of the stage. See the following screenshot for a hint:

Have a go hero

This will require you to rework the current scripts so that you can calculate a new number of steps to move based on the level and then store that new value in a variable.

You will also need a way to increment levels beyond what we have created. Time may not be the best option. Perhaps changing levels based on the score would be better.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.141.206