Create Your Own Computer Game

Learning to program with Scratch

Andrew Rowland | 1 Feb 2021 | 0 comments

When I started programming back in the mid-1980s, I had to learn a lot of commands and type them in. It was about turning text into something the computer could run, and you had to get it 100% right or it would throw up an error, which could be discouraging (but very exciting when it all worked!) Today’s youngsters are very lucky in comparison. They can learn using Scratch – and easily make games that would have been impossibly hard in my day. And it’s not just for kids. Why don’t you have a go? It can get addictive.

When you open Scratch, it is very visual. You see a large blank area called the stage, with just a cute cartoon cat in the middle.

Click for full-size image
Down the left side are shapes like jigsaw pieces that represent each of the ‘commands’, colour-coded to show what kind of command they are – things that control movement of the character, play sounds, react to events like a player pressing a key etc. Instead of typing and learning a lot of syntax, you just drag the shapes – blocks – into place with the mouse. As children drag the blocks around to get the right sequence of actions they are learning programming skills. Some of the blocks have small boxes where you can enter values. For example, if you want the cat to move forward, you enter the number of steps. Or if you want a message to be displayed, those words. If you have a number of steps you use often, define your own blocks and use them in your programs just like one of the built-in blocks – what programmers call sub-procedures. Soon, you’ll be changing the backdrop, using a variety of characters (called sprites) and turning the program into a game. And it isn’t just about controlling sprites: you can use it to control real live things like lights and motors and react to switches and sensors.

So how do you get started? Firstly, fire up a browser and type into the address bar. Next click the big Get Started button – and that’s it! There is a tutorial video right on the page to get the ball rolling. For best results, make a Scratch account so you can save your work for next time. You can also download the desktop version of Scratch, like the Raspberry Pi I covered last time has, and save to your own computer without an account.

Next, choose an example project from the Scratch home page. Open it and see how it works, then start to make changes. If it is a game, how might it be made more fun? Could you add a high score table or add new characters? Get your imagination running, and you will learn the programming as you go on. Alternatively, work through some of the video tutorials and put your ideas into practice from, well, scratch. The trick is to decide what you want to do and then find out how to do it. That way, learning is always purposeful and enjoyable. When you’ve done, publish your creation on the Scratch website so anyone on the planet can play it!

Of course, Scratch isn't limited to games. Almost anything you can think of to do with a computer can be created. And when you are ready, you can progress to a ‘grown up’ computer language like Visual Basic, C# or Python.

© Andrew Rowland 2021

Raspberry Pi 400
Blog Contents Page
You and the Internet

Comment or Ask a Question