To keep score, we need to set up a variable and add a conditional statement to increment the score when the ball touches a brick. Let's follow the given steps to add a score variable:
From the Data palette, click on the Make a Variable button to display the New Variable dialog box.
Type the word
Score
, and select the For all sprites option.Click on OK to add the variable. The Data palette displays several new blocks, and the Score reporter block automatically displays a monitor on the stage.
Position the score monitor somewhere on the stage where it won't interfere with the gameplay, such as in a bottom corner.
We will increase the score when a brick breaks, so let's work with the yellow brick sprite. Add the change () by () block from the Data palette after the broadcast (bounce) block in the when I start as a clone script. The default block values of score and 1 are correct.
Click on the green flag and play the game. Each time the ball breaks a brick...