Scratch Tutorial
Scratch Tutorial
Scratch Tutorial
INTRODUCTION
Scratch is a simple environment designed by the Kindergarden Lifelong Learning Group
at MIT to introduce some basic programming concepts in a fun and interactive manner.
In Scratch, sprites (objects) are manipulated on the stage (background) using various
scripts (small program segments). Each sprite has its own set of scripts to control its
behaviors and how it interacts with other sprites and events. Programming consists of
snapping together individual blocks of preexisting actions to create a script. A program
can be as simple as a single block or consist of multiple blocks stacked together that will
run as a unit.
STARTING SCRATCH
To start Scratch, click on Start > All Programs > Scratch > Scratch or follow the
instructions given by your Lab Instructor for your lab.
BASIC INTERFACE
When Scratch starts up, you will see a screen similar to the one below. The different
areas have been labeled for you and will be explained in more detail next.
Page 1
MENU:
This is how you can create a New project, Open or Save an existing
project, Save (a new project) as whatever name you choose, Undo a
previous action, and obtain Help.
BLOCK DESCRIPTIONS: The block description area lists the eight categories of blocks
including
,
,
,
, and
. The block
categories are all color coded so when you see a block of a specific color,
you can quickly determine which category it came from.
BLOCKS PALETTE: This area shows all of the blocks available to you for use in your
programming. Note that the blocks palette will change depending upon
the current block category. When you select a new block category, the
blocks palette will change to reflect the new options available.
CURRENT SPRITE INFORMATION: Here you will find the name and picture of the
current sprite together with its x-y position, direction, and rotation style.
TABS:
These tabs allow you to both see and change the current sprites scripts,
costumes, and sounds. The scripts tab shows you any scripts that
currently exist as well as to develop new scripts pertaining to the current
sprite. The costumes tab allows you to create (from scratch or from a file),
edit, or copy a costume. A costume is the visual image of the sprite onscreen. Sprites can have multiple costumes and use scripts to change
between them. The sounds tab displays the current sprites sounds.
SCRIPTS AREA:
This is where you create and view the scripts pertaining to the
current sprite.
STAGE:
The stage is where all of the action takes place. The stage is 480 units
wide by 360 units tall and the center of the stage is at x-y coordinate (0,
0). This means the lower left is at (-240, -180), the upper left is at (-240,
180), the upper right is at (240, 180), and the lower right at (240, -180).
TOOLBAR: A number of tools exist for your use. The arrow is the default selection
and it allows you to pick up and move sprites and blocks of code around.
There are also options for you to duplicate and delete items as well as
grow and shrink your sprite.
GREEN FLAG / RED STOP: Typically you click on the Green Flag to start your main
program(s) and the Red Stop sign to end them.
PRESENTATION MODE: This provides a full-screen view of the stage. To exit, use the
Esc key.
Page 2
NEW SPRITE BUTTONS: Using these buttons, you can paint a new sprite, choose a
new sprite from a file, or get a surprise (random) sprite.
SPRITE LIST: On the left, you will see a thumbnail for the stage. Clicking on this
thumbnail changes the Current Sprite Information area to reflect the
properties of the stage. Stages can still have scripts and sounds.
However, to change the appearance of the stage, you would select a
different Background as opposed to Costume. On the right, you will see
thumbnails of all of the sprites in the project together with the sprites
name, amount of costumes, and amount of scripts. You can easily
change the current sprite by clicking on a different one. When you do this,
the Current Sprite Information area together with the Scripts area are
updated too
EXPANDING A SCRIPT
To expand the script, simply snap a second block to the first. Scripts are executed from
the top to the bottom so you need to add the block accordingly. If you want the new
block to execute first, add it on top of the existing block. Otherwise, add it below. As
you drag a block into the Scripts Area, a white line will indicate where you can properly
join the new block with the existing script structure. When you are ready, you can
double click anywhere on the new script to execute it.
Page 3
REARRANGING A SCRIPT
To move a stack of blocks around, select the top block first and then drag it where you
wish. To split a stack, click on a block within the stack and pull it out. All blocks
underneath it will come too. You can continue to split the stack and move blocks
around to create a new script. Alternately, you can right-click on a block and delete it if
it is no longer useful or you can choose to duplicate it if you want an extra copy. As
well, Undo can be found in the Menu along the top if you need it.
Duplicating: Right-click on your current script and duplicate it
three times so you have a total of four copies. You may
need to move blocks around. When finished, your script
should look like Figure 1a. Try it!
Note:
Figure 1a
Page 4
to begin
Figure 1c
. Double-click
block on top
CLEANING UP SCRIPTS
If you right-click on the Scripts Area and select clean up from the menu, Scratch will
tidy up the scripts that youve developed.
Page 5
a
background yourself,
background from a file,
an
existing background, or
a
background (useful to do before editing).
Figure 2a
3. Select Import and find a background you like in one of the existing files (such as
Outdoors > brick-wall1). Click OK when ready.
4. Since you no longer need background1, you can click on the
You should now have an interesting background!
to delete it.
category.
Page 6
Figure 2b
Hint:
Figure 2c
Figure 2d
Page 7
The basketball acts more like a ping pong ball bouncing only back and forth. A
real ball would rotate as it moves around. To simulate this action, add the block
below the
Now the problem is that in only rotating one direction, we dont simulate gravity.
Our ball bounces all over the stage. We need to rotate in different directions
depending on which direction the ball is going.
or
template such as
from the
category). Notice that these blocks
have pointed ends and will only fit inside other blocks whose shape matches their own.
There are some preexisting reporters available to you that report different numeric
values such as
and
. When you click on the check box, a
monitor will appear on stage and show you the numeric value of this reporter. If you
double-click the monitor, you can change its appearance. Monitors are updated
automatically as the values they hold change. These reporters have rounded edges and
).
to close it.
Figure 2e
Page 8
SPRITE INTERACTION
In order for our sprites to interact, we need a means through which they can
communicate. This typically involves touching. When one sprite touches another, an
event occurs. We can capture this using a
and a
block to receive the message. The message sent can be
named whatever you wish. The only requirement is that the message sent and received
must be identical.
Broadcasting: Make Sprite1 (our dog) the current sprite by clicking on its thumbnail in
the Sprite List. When we happen to touch the ball, we want to send a message
indicating that were touching the ball. Since our dog gets excited when this
happens, hell say Woof!. Modify the initial script from Figure 2b into Figure 2f.
Test it and see what happens.
Figure 2f
Figure 2g
The problem is that if Sprite1 is not touching Sprite2 when the green flag is
touched, the message is not sent. We need to keep checking over and over so
that once the dog touches the ball, the message will be sent. Modify your script
to become that of Figure 2g and try it again. Your dog now realizes when he
touches the ball. We need to set the ball up to react when it is touched.
Receiving a broadcast: Make Sprite2 (our ball) the current sprite by clicking on its
thumbnail in the Sprite List. Change
into
Page 9
Figure 2h
If you try it now, it works as expected. You can experiment further to see what
happens if you replace the
with
. Change it back to
when finished.
VISUAL ENHANCEMENT
There are lots of creative ways to visually enhance the
scene. We can have the ball change colors or leave a
trail as it bounces. We can make this trail change colors
or even size. Figure 2i illustrates for you how to
accomplish these outcomes.
Try experimenting with some of the drop down menus
for different effects. For example, you could try whirl in
.
Figure 2i
References
1. Scratch Reference Guide:
2. Getting Started Guide:
3. http://scratch.mit.edu/howto
http://scratch.mit.edu/files/ScratchReferenceGuide.pdf
http://scratch.mit.edu/files/ScratchGettingStarted.pdf
Page 10