Today you are the programmer! People who make games write code that tells sprites what to do and when to do it. We're going to build a Penalty Shootout game in Scratch — you'll take a shot, and a goalkeeper will try to save it. Watch the board first as each piece is modelled, then build it yourself and run it to see what happens. Games like this use two big ideas real programmers use every day: loops to repeat an action, and events to decide when something starts.
Open Scratch on the IWB and show the finished game briefly so pupils know the goal. Explain the routine: watch the model, then build in pairs, then run it. Ask: <em>What jobs will our code need to do?</em> Circulate as pupils settle at devices. Remind pupils to share the device fairly and to stay on the Scratch website only.
Go to the Scratch website and create a new Scratch project. You can delete the cat sprite.
Go to the Scratch website using the link below and click on the 'Create' link in the blue bar at the top.
By default, each new project starts with the cat sprite already added. To delete the cat click on the x in the blue circle beside the cat in the sprite list.
Model creating a new project and deleting the cat sprite on the board. Check every pair reaches a fresh empty project before moving on. A common slip is starting to build inside an old project — make sure it is genuinely new. Support pupils who are slow logging in by pairing them with a ready pair.
Included with this step is a picture of a soccer goal, download this picture onto your computer and then upload it as a new backdrop in your project.
You can upload images as backdrops into your project. To upload a backdrop follow these steps:
The new backdrop will upload into your project and appear in the stage area.
Show where to upload the backdrop. Have the starter project link on the board for any pair who cannot save or upload the image — they can open that version instead so no one is left behind. Ask: <em>What is a backdrop and how is it different from a sprite?</em> Keep this quick so momentum stays on the coding.
Add the Soccer Ball sprite from the sprite library and give it the following code to set it up for the start of the game.
when green flag clicked
set size to (100) %
go to x (0) y (-130) // the bottom middle of the stage area
To add a sprite from the sprite library follow these steps:
You can use search box or the filter links (Animals, People, Fantasy etc) to locate your sprite.
Model adding the Soccer Ball sprite and the start-up code on the IWB. Key question: <em>Which event makes this happen?</em> (the green flag). Point out that the coordinates place the ball at the bottom middle. Watch for pupils attaching the code to the wrong sprite — check the correct sprite is selected before they build.
To take a penalty shot you will click with your mouse the spot in the goal where you want to ball to go. This means that you will be clicking the backdrop so add the following code to the backdrop to broadcast a message.
when stage clicked
broadcast [shoot v]
Messages are a great way to start a piece of code at a particular time. To create a new message follow these steps:
Model clicking the stage to add its code. Explain that clicking the backdrop <em>broadcasts</em> a message — like sending a signal other sprites can hear. Key question: <em>Who will be listening for the shoot message?</em> The common bug is placing this code on a sprite instead of the stage; check the backdrop is selected.
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.