Lesson 6

1. In the previous lesson, you programmed a game. In this lesson, you’ll be adding a scoring system! This way, you’ll be able to monitor your progress and become a better player. Shall we do it?

2. Open the code you programmed in the previous lesson. Go to File and click Load from your computer. Select the Game.sb3 file and click Open.

3. You now have your game code open in Scratch.

First of all, you’ll create a variable that you’ll call Points. You can think of variables as boxes where you can save some values for the computer to use later. In this case, the Points variable will save the points scored in the game. Go to Variables and select Make a Variable.

Write Points in the New variable name: and select OK.

The Points variable should appear.

You want the game to always start with zero points. To do this, still in Variables, drag the block set “my variable” to “0″ to the beginning of the code, just below the block When green flag clicked. Change “my variable” to “Points”,  as in the figure.

Drag the block change my variable by “1” into the block if touching Paddle, then and change “my variable” to “Points”, as in the figure. So, every time the Ball touches the Paddle, you get a point.
Select the green flag and test your game!

Is it working? Perfect! If not, review everything you’ve done so far and try again!

4. Now, can you make your game more challenging? Of course you can! You’re going to speed up the ball when the number of Points exceeds 15, and thus make the game more difficult. In Control, select the block if_, then and drag it into the block  if touching Paddle, then as in the figure.

Then, go to Operators and drag the “_” > “_” block into the if_, then block.

Go to Variables and drag the Points block into the “_” > “_” Operator. Insert the number “15” in the right-hand space of the Operator so you have Points > “15”, then.

After that, in Motion, drag the block move “10” steps into the block if Points > “15”, then. Change the number of steps to “15”.

5. Try playing now! As soon as you go over the 15-point barrier, the ball will start moving much faster! Can you catch it?

6. After all this work and everything you’ve learned, can you make your game even more challenging?

While you wait for the next Theme, continue exploring in Scratch!

Scroll to Top