Getting Started with Scratch
Scratch is a visual programming tool which allows the user to create animations and games with a drag-and-drop interface. It allows you to create your own computer games, interactive stories, and animations using some programming techniques without actually having to write code. It’s a great way to get started programming on the Raspberry Pi with young people.
You'll find Scratch in
Programming. Once opened you will see a window like this:
Make the Scratch cat move
The cat in the white preview window is an example of a sprite in Scratch. Currently the Scratch cat sprite is on a blank stage. Let's get the cat to move.
- Click on the Scratch cat sprite.
- Then click on the blocks palette and select Control.
- Next drag a When green flag clicked block and place it on the scripts area in the middle of the screen.
- Add a blue Move 10 steps block from the Motion blocks palette and connect it to the When green flag clicked block.
- Now click the green flag icon in the top right hand side of the screen and see the cat move!
- How would you get the cat to move further?
Changing the way the sprite looks
All sprites in Scratch can wear different costumes.
- Click on your sprite to select it. In the Scripts area in the middle of the screen, click on the Costumes tab.
- You will see that the cat has two costumes. Click on Copy to make a third costume and a new cat costume should appear.
- Select costume3 and click on Edit. This will open the Paint Editor. Experiment with all the buttons and tools to find out what they do.
- Next, draw some clothes on the costume and click OK.
- To switch between costumes, click on the Scripts tag. Add the purple Looks block, Switch to Costume, to the other blocks and connect it.
- Select costume3 from the drop-down menu on the purple block.
- Now run your program to see the costume change.
If you feel that the Scratch cat sprite does not suit your needs then you can add other sprites, or even create your own!
- At the top of the Sprites palette are three icons to create a new sprite.
- The first allows you to Paint your own sprite. Click on this and it will open the Paint Editor window. Here you can use shapes, lines, and freehand drawings to make fun characters.
- The second icon allows you to Choose a new sprite from those already built into Scratch or saved on your Raspberry Pi. Click on this, and you will be able to navigate to the folders containing those sprites and select one you like.
- The third icon will, when clicked, give you a surprise sprite. Click this and see what happens!