1.2.3 – CODE YOURSELF – Programming in Scratch


Now, let’s start coding in Scratch. When you start Scratch,
you’ll get a screen like this one. We have given names to
each of these areas. The blocks in the Block
area are dragged and dropped into the Program area,
also known as the Script area. Each type of block has
a distinctive color. At the bottom, we have the Stage,
which can have different backdrops. And here, we have the Sprites, which are the characters that you
can program to tell them what to do. To run a program, you’ll click the green
flag or double-click the Script. You can resize the execution area by
pressing the arrow that appears in the bottom-right of the area. Now, let’s try out different blocks
in Scratch to get a better idea. Try to drag and drop the move 10
steps block into the Program area and double-click it. The cat will move in the direction
it is currently facing. You can change the amount of steps. Try, for instance, typing 100 and
double-click it to try it out. We can also tell the cat to bounce
if it hits the edge of the screen. To do this, simply drag the if on edge,
bounce block and put it under the previous block,
like this. Try running it by double clicking it,
to see what it does. If you don’t want the cat to turn
upside down when it bounces, press over the i on Sprite 1. Try selecting different styles
of rotation, and run the program. Now, let’s change the cat’s color. Go to the Looks palette, take a change
color effect by 25 block, and connect it to the previous block
placing it right underneath. Double-click the code
stack to run the program. Every time the cat moves,
it changes color. To be more precise, whenever we run
the program, the cat first moves, and then changes color. Executing our code from top to bottom. This program runs very fast so we can’t see the order of
execution with a naked eye. If you would like to observe more
closely the sequence of execution, you can introduce a wait 1 second
block from the Control palette. And place it between the two other blocks. When you run it this time, there’s a one-second pause between
the cat moving and changing color. Now, let’s remove the wait block
to continue with our script. We’ll now get the cat to meow. Introduce a play sound block from
the Sound palette, setting it to meow. And place it right underneath
your stack of code. Double-click the stack to run the program. [SOUND] The cat now meows. Great. Another way to run a program
is by pressing the green flag, which is on the top-right
of the execution area. To do this, you have to add
the when green flag clicked block, which is at the Events palette. To run the program, press the green flag. [SOUND] We’re going to be creating many
different programs in this course, so it’s important to give
them representative names. Every project can be saved,
so you can work on it later. This is very useful as you may come
up with new ideas to extend and improve your programs. If you’re working on the offline version,
go to File and Save. If you’re working on the online
version and are logged in, the program is saved automatically
with the name you gave it. If you’re working online anonymously, and
want to save your project, go to File and Download to your computer. It will ask you where to download
the file, and what name to give it. Note that Scratch files end in .sb2. If you named your project First Example, it will be saved as FirstExample.sb2
in the folder you selected. In the previous version of Scratch,
the files end in .sb. But no worries, files that were created
in the previous Scratch version can be used in this version too. If you want to work on your
project again later on, you can simply open the file
when working offline. Or upload from your computer
when working online anonymously. Well done. You’ve created your
first computer program. Let’s keep trying out Scratch.

Leave a Reply

Your email address will not be published. Required fields are marked *