0% found this document useful (0 votes)
28 views

Pong

The document describes how to code a basic Pong game in Scratch. It involves creating sprites for a ball and paddle, adding code to control the paddle with mouse movement and have the ball bounce off the paddle and floor. It also includes tracking the number of lives and adding a variable to count ball bounces.

Uploaded by

LBPPS teacher
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Pong

The document describes how to code a basic Pong game in Scratch. It involves creating sprites for a ball and paddle, adding code to control the paddle with mouse movement and have the ball bounce off the paddle and floor. It also includes tracking the number of lives and adding a variable to count ball bounces.

Uploaded by

LBPPS teacher
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Pong

Control the paddle using the mouse. 3


lives – if the ball touches the floor, you
loose a life. It also shows the number of
times the ball bounces.

RIGHT mouse click on the cat and select


'delete'

Click on the 'new sprite' button

Select the Ellipse tool

Make sure the 'solid' fill is selected below

Draw a very small ellipse (holding down


SHIFT) will make sure it's a perfect circle.

Click OK.

With the sprite selected, rename it to


‘ball’

Now for the paddle… click ‘Paint new


sprite’.

Draw a small paddle using the rectangle


tool, in a colour of your choice.
Click and drag the paddle towards the
bottom of the stage.

Rename the paddle sprite to ‘paddle’.

Click on the ‘ball’ sprite

Add the code as shown.

When the flag is clicked, the ball will


ALWAYS shoot upwards in a random
direction.

Those physicists amongst you will realise


that we’re not using the proper laws of
physics!

Press the green flag to test it so far…

Click on the paddle.

Add the script as shown.

The paddle will be controlled by the


mouse.

Keeping track of the number of


‘lives’…
Click on ‘Variables’.

A variable stores the value of something.


We might have variables to store the
number of ‘lives’, ‘score’ or someone’s
name.
Click ‘Make a variable’
Type in ‘lives’ and click ‘ok’.

Click on the ‘stage’

Add blocks as shown.

Create another sprite, call it ‘floor’. This


is a rectangle at the bottom of the screen.

Change the blocks on the ball sprite to as


follows:

Save.
Try it out!
TASK: Add a ‘bounces’ variable, that
keeps score of how many times the ball
bounces.
TASK: modify the theme.

Finished this? Try creating another game: ‘Catch the egg’. An egg (or similar object) falls from
the top. When you click on it, it glides to a random position at the top of the screen and begins
to fall again, but a little faster. If you catch it 6 times, you win. If the egg touches the floor,
you loose.

You might also like