0% found this document useful (0 votes)
142 views4 pages

Scratch Lesson 2 Simple Pong Game FOR SCRATCH 2

This Scratch lesson teaches students how to create a simple pong game. It instructs them to create sprites for a ball and bat, and move the bat using keyboard controls. The ball is programmed to bounce off the edges of the screen. An "if/else" block checks for collisions between the ball and bat, reversing the ball's direction if they collide. It also ends the game if the ball touches a red floor sprite. The lesson encourages students to add extensions like sound effects or a second player.

Uploaded by

Warwick Wu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views4 pages

Scratch Lesson 2 Simple Pong Game FOR SCRATCH 2

This Scratch lesson teaches students how to create a simple pong game. It instructs them to create sprites for a ball and bat, and move the bat using keyboard controls. The ball is programmed to bounce off the edges of the screen. An "if/else" block checks for collisions between the ball and bat, reversing the ball's direction if they collide. It also ends the game if the ball touches a red floor sprite. The lesson encourages students to add extensions like sound effects or a second player.

Uploaded by

Warwick Wu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SCRATCH lesson two

simple pong game


Creating the bat and ball
RIGHT mouse click on the cat and click
'delete'

Click ‘Paint new sprite”

Use the circle tool to create a ball.


Set its costume centre.

You can resize the sprites if they are too big or


too small

Create a blue rectangle for the bat.

Create a red line sprite to act as the wall


area that the player must protect.
This line needs to be the width of the screen

Resize if you need to

You should end up with a screen looking the


example on the left.

Checkpoint
You should have THREE sprites.
One called ‘Ball’ one called ‘Bat’ and one called ‘Floor’.
Page 1 of 4
Moving the bat using SELECTION
Select the bat sprite.

Add the blocks as shown.

We will use a FOREVER IF statement to check for a


keyboard press – the bat will move left if the player
presses the left arrow key

Move – 5 steps moves the bat left

We need the same thing to move the bat right if the


player presses the right key.

Duplicate the code by right clicking on it.

Change it so the right key moves the bat 5 steps

moving the ball


This block will position the ball roughly near the
top/centre of the screen

It will be pointed in a downward direction

Add the extra control blocks as shown.

The ball will now travel downwards until it hits the edge
of the screen, in which case it will bounce.

To make the ball move faster, change the “move 5


steps” value to a larger number. To make the ball
move slower, change the number to a smaller value.

We use the forever loop to make sure that the ball


continues to move and bounce.

Page 2 of 4
Save the game and test it if you like

We now have a moving ball, but we need to check


whether it hits the bat, or the red area.

checking for collisions

We use this IF statement to see if the ball hits the bat

If so, the program will reverse the direction of the


ball.

It does so using an OPERATOR – drag the green


operator block in first

Then drag the direction block into the first box and
type 180 into the second

Add this bit of code after the ELSE command

This will end the game if the player’s ball touches the red
area.

Now save your game and test it.

If it doesn’t work check your program against the example


in this worksheet.

Page 3 of 4
pong extension

Does your pong game work? Good! See if you can develop it further….

Why not add sound effects?

How about a sound each time the


ball hits the bat?

To extend your learning 1) You could add controls and graphics for a
further: second player.

They could have a bat and “target” area at the


top of the screen.

2) You could add additional targets for the player


to avoid – these could be sprites or shapes.

You could create a “win game” target

When you have finished, explain your learning:

Comment on what you have done and why

Explain how SELECTION has been used in your


program

Right click on the screen and select save picture of


scripts

Save the image into your area. Insert it into Word,


and print out your work adding any additional
annotation if necessary

Page 4 of 4

You might also like