Time for action – keeping a global scoreboard
Currently, there are two conditions in our script that signify the end of the game. The first is when the player clears the level. The second is when the player's lives become zero. Because we have some duplication, we'll use a custom block to set the score. The steps are as follows:
- With the ball sprite selected, select the More Blocks palette and click on the Make a block button to create a block named update scoreboard.
- Add the scoreboard block to the when I receive (level clear) block.
- Add the scoreboard block before the stop (all) script in the if ((lives) = (0)) then block.
- We need to add a new cloud variable to use in the define update scoreboard block. From the Data palette, click on the Make a variable button. Name the variable scoreboard and select the cloud variable (stored on the server) checkbox.
- When you click on OK to create the project's first cloud variable, you will get an information box that tells you the...