Scratch Lesson 7: The Pong Game

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Scratch Programming

Lesson 7: The Pong Game

In this lesson, we will explore a sample game named “Pong”. This game is
simple so it's a good place to start learning how to create a 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.

ShallWeLearn | shallwelearn.com
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.

ShallWeLearn | shallwelearn.com
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:

ShallWeLearn | shallwelearn.com
The Combo block shown is activated The combo block shown is activated
when the ball hits Stage’s red bottom. when the ball hits the edges of the
Stage.

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

ShallWeLearn | shallwelearn.com
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.

ShallWeLearn | shallwelearn.com

You might also like