Scratch is an easy to use programming language used to teach children to code
Hi and welcome to my first hub on Scratch. This free programming language was built by a team at MIT and is designed to be used by children between the ages of 8 and 16. Creating a programme incredibly simple and intuitive and is similar to building something using Lego. Children combine together coloured blocks to create a programme.
In the US and the United Kingdom it is used in schools to introduce children to coding as it allows them to learn the basics of how to code interactively. Students using Scratch can quickly build code with variables, loops and other commands by moving coloured blocks into groups to create programmes simply and easily. It is also used in Code Club, a volunteer run organisation in the UK that teaches children to code in after school or lunch time classes.
There are two versions of Scratch. There is an off-line version (1.4) and an on-line version (2). There are a small number of new commands in 2, otherwise the two are identical.
It is a popular tool in schools and as well as being used to teach children programming, it can be used in projects for:
- Maths and science
- Interactive art
There is also a strong on-line community where people can share ideas and upload their projects so that others can see and use them. You can see below examples of just some of the amazing Scratch games that have been created.
Introduction to the main Scratch interface
The main Scratch screen is divided into three sections. You can see that both version 2 and 1.4 have the same parts, but in slightly different places. In effect, in version 2, they have moved the stage from the right hand side to the left hand side.
The first pane we will look at is the left pane in 2.0 (right hand pane in 1.4). You can see that it is made up of two parts.
The Stage panel in Scratch
The upper part (the Scratch Cat on a white background) is the part of Scratch where your final project will run. You can use the green flag to run it, and the red circle to stop it.
In the middle, you have three buttons that allow you to manipulate the sprite (the Scratch Cat is our sprite at the moment)
- The first button enables you to upload a picture from the library (2 only)
- The second button allows you to paint a new sprite
- If you want to load a new sprite from a file, click the second button
- To load a sprite directly from your camera, choose button four (also 2 only)
- Version 1.4 has a third button, Get Surprise sprite which loads a random sprite
The Sprite List panel in Scratch
The area in the bottom left (bottom right in version 1.4) shows you all the sprites that you currently have loaded as well as the Stage button which allows you to make changes to background for your project (you can see to the right that Scratch is now on the Route 66 as I changed the backdrop).
The Scripts Area in Scratch
The next area is the Scripts Area. This is on the right hand side (version 2) or the middle section (version 1.4) which is used for two things:
- First, when you click on something in Scratch, any tabs that are available are shown here. If you click on the Stage button in the bottom right, you will see the Scripts, Backgrounds and Sounds tabs if you select a sprite, the tabs will change to Scripts, Costumes and Sounds.
- The second function is as a work space for the blocks that you will combine together to create whatever it is that you are making using Scratch.
- In Scratch 2, the small picture of the Scratch Cat shows you the exact co-ordinates of your sprite
- Again only in version 2, the bottom right has zoom in and out buttons, should your code get too big to be seen on the screen all at one time
The Blocks Palette in Scratch
The left hand pane (middle pane in Scratch 2) contains all the blocks that you will use to build you game, story or animation. They are separated into eight sections based on their function. The eight groups are:
- Motion – controls the movement of your sprite
- Looks – alters the appearance the sprite
- Sound – adds sound to your project
- Pen – controls your pen should you use one
- Control (split into Events and Control in version 2) – determines how you interact with your sprite
- Sensing – using these blocks you control how the sprite interacts with the stage
- Operators – these blocks allow you to add mathematical operators (+ - * / etc)
- Data (Variables in 1.4) – use this section to create and manipulate variables
- More Blocks – allows you to create new blocks (available only in version 2)
Building a simple programme using Scratch
Now that we know all the parts of the screen, we will now build a small program to control the Scratch Cat. We want Scratch to move right when the right arrow is pressed.
We are going to begin with a Control Block so that we can define how the programme will be started.
- Click on the orange Events button (Controls in version 1.4)
- Drag the when space key pressed block from the Block Palette
- Select the drop down menu on the block we just added and choose right arrow
Next, we want the Scratch cat to face right:
- Select the dark blue Motion button
- Move the point in direction 90 block under the orange block we just added (ensure that the blocks click together as if they were Lego bricks)
Now we want Scratch the cat to move:
- Still looking at the dark blue motion blocks, select move 10 steps and place it below the two bricks
Our simple programme is now complete. If we double click our group of three blocks, you will see Scratch move to the right. This shows us that the programme moves Scratch to the right.
To fully test it click the green flag icon in the very to right corner. When you press the right arrow Scratch moves to the right, otherwise he just stands there which is exactly what we wanted!
If Scratch ends up going off the screen, just select him and drag him back to the middle of the stage.
Building a more advanced programme in Scratch
Scratch becomes really powerful when you combine two (or more) separate programmes together. We are going to build on the programme we just created and add another, so that when we press left, Scratch the cat will move left. To do this:
- Right click on the first group of blocks and select Duplicate
- For the second set of blocks, change space to left arrow and point in direction -90
To test each part we can double click it to check that Scratch the cat behaves as we would expect (moving left and right) and to run the overall programme we press the green circle in the top right corner.
You can finish this off completely by adding programmes for up and down so that Scratch the cat will move in any direction.
Scratch is an excellent (and free) programme that allows you to create art, music and educational projects as well as programmes and even games that can then be shared via the web. It is an excellent tool for schools and parents and children love to use it. In today’s hub, we looked at the Scratch interface and at its three component parts:
- The Stage
- Script Area
- Block Palette
Once we were familiar with the different areas of Scratch and what we use them for, we then learnt how to create programmes. We created some code using coloured blocks to move the Scratch Cat to move right when the right arrow is pressed.
Scratch becomes even more powerful when you combine sections of code together. We did that by adding a programme to move Scratch the cat left, up and down when the corresponding arrow key is pressed.
As with many creative tools such as Scratch, the sky is the limit and you are confined in what you can create only by your imagination. This is why it is such a powerful tool and also why it is so loved by children, parents and teachers alike. I hope that you have found this hub useful and informative, please feel free to leave a comment below and thanks for reading.
© 2014 Robbie C Wilson