- Start to use Scratch
- To create a simple “Hello world” program.
- Create code to move the sprite around the screen.
- Using the “pen”, draw shapes on the screen.
All must access Scratch, and create a basic “Hello World” program. Use the blocks of code to make the sprite move, and then save work in the browser. Take a screenshot of the code, and print out for book (Level 4)
Most should complete the above, then with some help draw more complicated shapes. (Level 5)
Some could complete the above, creating more complex shapes with no help, and include output messages in the program. Annotate the screenshot, describing how the program works. (Level 6)
Words to learn: Sprite, graphical language, text based language
To begin with, we’re going to look at ways of giving instructions to a computer. Click here to visit RoboZZle – a programming puzzle game, which requires you to create a sequence of instructions for a Robot to follow. Look how very complex behaviour can be created with a few commands.
Each level you complete of Robozzle needs you to think about using a very small set of commands or instructions in a particular order to complete a task. This is problem solving (more of this later).
Main – Opening Scratch
Now you’ve looked at using a small set of commands to solve problems, we’re going to look at something a bit more useful. You may remember using “Scratch” at primary school for simple programmes. Now we’re going to use it to write more advanced code. This is a graphical programming language, in that you drag small pictures of code (or blocks) which snap together to give you a set of instructions. This is basically a more complicated form of RoboZZle. As you study more computing, you will learn to use text-based languages, where you type commands onto the screen. Now we’re going to look back at Scratch which is a great starting point for more serious programming.
Open up Scratch (click the Start button, select “All Programs”, then “PROGRAMMING”, then “Scratch” and click on “Scratch 2”).
The first time you run Scratch 2 it may need to set up Adobe Air, let your computer do so. If you get any messages about updating Scratch just click Cancel.
This should look familiar…
Main – Hello World
We start by making a “Hello world” program (always the first thing programmers try in a new language!)
Looking carefully at the colours of these two blocks of code, (you have a colour-coded menu at the top right) drag the blocks from the left hand side of the screen into the empty space in the middle. Now click the green flag at the top right. What happens?
- Can you make the cat say “Goodbye” for 5 seconds?
- Now can you make it say this rhyme, line by line?(Each line should be replaced by the last one)
“The sausage is a cunning bird,
with feathers long and wavy.
It swims around the frying pan,
and makes its nest in gravy… “
Main – Get Moving
Now let’s make things more interesting. In a new program copy this script:
and click the green flag.
- What does this program do? (Describe it line by line)
- Why do you think we need the “wait” block in the program?
- Does the program end in the same state it was in when it started? (Is everything the same?)
Main – Save me!
It is vital at this point to start saving your code. Make a “Scratch” folder inside your “Computing” folder in your H: drive.
Click on the “File” menu entry at the top left of the screen, click “save as” then type “firstProgram”:
Make sure you have selected your “Scratch” folder on your H: drive. Make sure you save your code regularly from now on – don’t run the risk of loosing your work.
Main – Draw
Now we’ve made the arrow sprite move around a bit let’s make things even more interesting…
Start a new program (Go to the File menu and then choose “new”) then copy this code:
then click the green flag. What happened?
- That was easy. Change your script to draw a whole square.
- Change your code to draw a second larger square in a different position.
- Take a screenshot of your “Two square” code (ask your teacher if you don’t remember how) and print it out for your book/folder. You should write some notes explaining how the code works, and what the different blocks of code do.
- Make the sprite output (say) “Drawing a square” before it starts, and “finished drawing” as it completes each square.
- Now add a triangle to the picture.
- How about a hexagon?
- Perhaps you could make it spell your initials?