Scratch Lesson 7: Understanding the Pong Game

In this lesson, we will modify a sample game named “Pong”. We will add score, levels, and more balls to the game.

To open the “Pong” game, click “Open” and browse to Projects->Games, and then select “Pong”. Click OK to open the Pong project.

There are two sprites: ball and paddle. The ball sprite moves randomly by its own, whereas the paddle sprite is moved by user moving the mouse.

Click the green flag to try the game. Use the paddle to hit the ball as it falls down. You should soon find that if the ball hits the bottom of the Stage, the game would end.

*

The ball sprite has three combo blocks. You can think of a sprite as a robot and each combo block as a separate motor. Just like a robot is controlled by many motors, a sprite can be controlled by many combo blocks. In Computer Science language, each combo block is a thread of execution, working independently of the other threads.

In the picture shown left, first combo block controls how the game would end – if ball touches red, then game ends.

The middle combo block checks whether the ball has touched the paddle and takes action when it does.

The last combo block checks whether the ball has hit the edge and takes action when it does.

The image below shows how a sprite moves in the Scratch stage which is based on the X-Y coordinate system.

 

This sprite moves according to this script:

 

The Combo block shown is activated when the ball hits Stage’s red bottom.

The combo block shown is activated when the ball hits the edges of the Stage.

* *

The combo block shown is activated when the ball hits the paddle.

                                  

* *

TRY THIS: Try changing the randomness by changing the value in “pick random ? to ?” block. To make it more random and the game more difficult, increase the range of the degree change.

         

Also, you can make the ball leave trace of its movement by using the Pen Tool Kit.

5 Comments

  1. Magnificent website. Lots of useful info here. I am sending it to a few friends ans also sharing in delicious. And of course, thank you on your sweat!

  2. Ada Koppejan

    How can I get a copy of the sample games you use in your videos?

Comments are closed