Paddle Ball

Cymraeg

Make Your Own Paddle Ball Game in Scratch

This is a step-by-step guide for making a paddle ball game in Scratch. You can either complete the challenges (advanced users), attempt the challenges using hints (intermediate users), or use the video tutorials (beginners).

Getting Started

You will need the Scratch software for this workshop. This is available free either in browser or as a desktop application. For the software and related information, go to scratch.mit.edu

If you are new to Scratch, we'd advise you to have a look at the basic space game workshop first.

Load up a new Scratch file and delete the default cat sprite to give you a completely empty project before starting on the challenges.

Basic Game Structure

The first section of challenges aim to help you recreate the basic game structure as shown below.

Select speed and press spacebar to start demo

Challenge One: Bouncing a ball

Make a ball sprite that, when spacebar is pressed, starts bouncing up and down the screen continuously.

  1. The starter block needs to be set to the 'space' key

  2. You will need to set the direction so the ball travels up first

  3. Look for a block that will 'bounce' the ball off the edges instead of crashing into them

  4. Ensure the ball travels continuously

Below are the script blocks needed (in the same order as the Scratch menu - you will still need to work out how to connect them). For the completed script see the video tutorial opposite.

Challenge Two: Making the paddle

Produce a paddle that travels left and right, following the mouse, near the bottom of the screen

  1. You will need to have a set value for 'y' (the up/down position)

  2. There is a 'mouse x' variable, where 'x' is the left/right position...

  3. You may need to stop any rotation of the paddle too

Below are the script blocks needed (in the same order as the Scratch menu - you will still need to work out how to connect them). For the completed script see the video tutorial opposite.

Script block for movement

Script block to stop rotation

Challenge Three: Interaction of ball with paddle

Program the ball to 'bounce' off the paddle

  1. The ball needs to detect contact with the paddle

  2. The simpler solution requires a suitable direction change on contact (190 works well)

  3. For more realistic bouncing, see the extensions section

You will need to add the below code blocks to the ball script

Challenge Four: Building bricks

The game requires bricks that disappear when hit by the ball

  1. Start with scripting one brick before duplicating

  2. You will need to use 'show' and 'hide' code blocks

You will need to put the below code blocks together to form a script for a brick

Challenge Five: Scoring

Introduce a score system that goes up each time a brick is 'destroyed'. Use this to also determine end of game once all blocks destroyed.

  1. You will need to create a variable for 'score'

  2. Make sure it goes up each time a brick is destroyed

  3. Set a maximum score that ends game on destruction of last brick

You will need to find the right places to include the below coding blocks

Challenge Six: Variable ball speed

We need a variable slider to set the ball speed for the game.

  1. Right click on a variable on the stage to get options

  2. Make sure this figure then feeds into the ball script

You will need to use the below blocks to complete this challenge.

Challenge Seven: Lives

The player should have 3 lives. These need to be illustrated in the bottom left corner and one lost everytime the ball hits the bottom of the screen. Game should stop when all lives are lost.

  1. You will need to use a sprite and costumes to show how many lives are left

  2. A new variable of 'Lives' will be necessary

  3. How will you mark out the bottom area for the program?

  4. Need to deduct a live whenever the ball misses the paddle

  5. You may need a slight delay before resuming to make sure only one live is lost each time.

Finishing Touches

Having completed the basic scripts for an operational paddle-ball game, it is now time to add some finishing touches and personalise it.

Here is a list of things you may wish to consider doing:

Extension Activities

Make the ball bounce more realistically off the paddle and bricks.

In challenge 3 we made the ball 'bounce' of the paddle, the easiest way to do this was to change the direction by a set amount. This did not recreate a realistic bounce such as that seen when the ball hit the edges. So how can we correct this?

To do this we will need to replace the 'turn' motion with a 'point in direction' block. Then using an operator block set the direction to 180 - 'direction'.

The problem now is that the bounce will be realistic, but the ball will get stuck easily on a set route. To correct for this we need to change the block so it reads:

Point in direction 180 - direction + pick random -10 to 10


Ping-Pong

Now that you have completed this workshop to create a paddle ball game, you should be able to take what you have learnt and use it to create your own version of 'Pong'.

Share your game

If you are willing to share your final version with others, please upload your project to Scratch and send the link to nar25@aber.ac.uk