Scratch
Programming language
Programming is the art of writing instructions to tell a computer what to do. A set of instructions is called
a program.
Scratch is a programming language developed by the MIT Media Lab for the purpose of teaching
programming to teens and other first-time programmers. Scratch allows new programmers to create
programs by snapping together blocks. Scratch consists of a programming language made up of different
blocks and an easy to learn graphical development environment that includes a paint application for
creating graphics and built-in sound editing capabilities. Scratch also comes with huge collections of
sample applications as well as graphics and sound files, all of which you can use to create your own
Scratch projects.
Why Scratch?
Scratch provides everything needed to begin developing computer games, multimedia presentations,
interactive stories, graphic artwork, and computer animation. Scratch can be used to play digital music
and sound effects. Scratch’s building block approach to programming sets it apart from other
programming languages. This makes Scratch easier to learn. And yet Scratch provides plenty of
programming power, allowing you to build very powerful application projects.
Scratch is easier to use than most other programming languages for a number of reasons:
You don’t have to remember or type any commands: they’re all on screen, so you can just drag
and drop them.
Commands fit together like jigsaw pieces, so there are strong visual hints about how you can
combine them.
Error messages are rare. Because Scratch commands lock together
The commands are color-coded and categorized, so you can easily find a command when you
need it.
Scratch enables you to quickly see results from your work, and even includes graphics and sounds
Scratch doesn’t cost
it works on Windows, Mac, and Linux computers
SCRATCH APPLICATION
Scratch application projects are made up of objects called sprites. A sprite is a two-dimensional bitmap
image drawn on a transparent background. Sprites can be moved around and made to interact with one
another. Sprites consist of three primary components, as outlined here:
Scripts. - Collections of code blocks that outline the programming logic that controls the
operation of sprites.
Costumes. - Images that are used to display the sprite on an area of the Scratch IDE, referred to
as the stage. Sprites can consist of any number of costumes.
Sounds. - Sound effects that are played during application execution when certain events occur
or as background audio.
Stage: This is where you can see your animations and games in action. When Scratch starts, there’s a
large orange cat in the middle of the Stage.
Sprite List: The cat is a “sprite”, which is like a character or object in a game. You can see all the sprites
that are in your project, and click them to switch between them. The Sprite List is below the Stage.
Blocks Palette: The Blocks Palette presents you with all the blocks you can use.
Code Area: The Code Area is where you make your programs, by joining instruction blocks together.
When you join blocks together, the result is called a script.
Backpack: The Backpack at the bottom of the screen is handy for copying sprites and scripts between
different projects.
SCRATCH BLOCKS
MOTION MOVEMENTS AND
POSITIONS
LOOKS
COSTUMES & MANNER
SOUND
VOICE
PEN SHAPES & COLOR OF THE DRAWINGS
DATA MANAGE VARIABLES
CONTROL CONDITIONAL STATEMENT
SENSING SCREEN CONTROL MOUSE KEYS & TIMER
EVENTS COMPUTER CONTROLS
OPERATOR
CALCULATIONS
S
MORE
BLOCKS ADD CSTOMIZED CODE GROUPS
Motion blocks
Motion blocks are the blocks that control a Sprite's movement. There are 17 Motion blocks in
Scratch 3.0.
Scratch 3.0 has the following fifteen Motion Stack blocks:
movesteps — Moves the sprite forward the number of steps in the direction the sprite is
facing.
turndegrees — Turns the sprite (clockwise) the specified amount.
turndegrees — Turns the sprite (counter-clockwise) the specified amount.
pointindirection — Points the sprite in the direction.
pointtowards — Points the sprite towards the mouse-pointer or another sprite.
gotox:y: — Moves the sprite to the specified X and Y position.
goto — Moves the sprite to the mouse-pointer, a random position, or another sprite.
glidesecstox:y: — Glides the sprite to the location, taking as long as the specified amount
of time.
glidesecsto — Glides the sprite to the mouse-pointer, a random position, or another sprite,
taking as long as the specified amount of time
changexby — Changes the sprite's X position by the amount.
setxto — Sets the sprite's X position to the specified amount.
changeyby — Changes the sprite's Y position by the specified amount.
setyto — Sets the sprite's Y position to the amount.
ifonedge,bounce — If touching the edge of the screen, the sprite's direction flips over
setrotationstyle — This sets the rotation style of a sprite.
Scratch 3.0 has the following three Motion Reporter blocks:
xposition — The X position of the sprite.
yposition — The Y position of the sprite.
direction — The direction of the sprite.
Looks blocks
Looks blocks are the blocks that control how a sprite looks. There are 23 Looks blocks in
Scratch 3.0. Three of the 19 sprite Looks blocks have a counterpart for the Stage.
Scratch 3.0 has the following eighteen Looks Stack blocks:
sayforseconds — A speech bubble appears over the sprite and stays for the specified
amount of time.
say — A speech bubble appears over the sprite and will not go away over time.
thinkforseconds — A thought bubble appears over the sprite and stays for the specified
amount of time.
think — A thought bubble appears over the sprite and will not go away over time.
show — Shows the sprite.
hide — Hides the sprite.
switchcostumeto and switchbackdropto — Changes the
sprite's/Stage's costume/backdrop to the specified one.
switchbackdroptoandwait — Like the Switch to Backdrop () block, though it waits until all
of the hat blocks triggered by this have completed. (Stage only)
nextcostume and nextbackdrop — Changes the sprite's/Stage's costume/backdrop to the
next one in the costume list.
changeeffectby — Changes the specified effect by the amount.
seteffectto — Sets the specified effect to the amount.
cleargraphiceffects — Clears all graphic effects on the sprite.
changesizeby — Changes the sprite's size by the amount.
setsizeto% — Sets the sprite's size to the amount.
gotolayer — Puts a sprite in the front or back.
golayers — Changes the sprite's layer value by the amount.
Scratch 3.0 has the following three Looks Reporter blocks:
costume and backdrop — The number or name of the sprite/Stage's current
costume/backdrop in the list.
size — The sprite's size.
Sound blocks
Sound blocks are the blocks that control sound. There are 16 Sound blocks in Scratch 3.0.
The note blocks in 3.0 have been moved to the Music Extension.
Scratch 3.0 has the following eight Sound Stack blocks:
startsound — Plays a sound without pausing the script.
playsounduntildone — Plays a sound and pauses the script until it finishes.
stopallsounds — Stops all playing sounds.
changevolumeby — Changes the volume by the amount.
setvolumeto% — Sets the volume to the amount.
changepitcheffectby — Change the pan left/right or pitch by the amount.
setpan left/righteffectto — Set the pan left/right or pitch to the amount.
clearsoundeffects — Clears any sound effects currently in place.
Scratch 3.0 has the following Sound Reporter block:
volume — The volume.
Events blocks
Events blocks are blocks that control events and the triggering of scripts. There are 8 Event
blocks in Scratch 3.0.
Scratch 3.0 has the following six Event Hat Blocks:
whenclicked — When the flag is clicked, the script activates.
whenkeypressed — When the specified key is pressed, the script activates. The event will
only be triggered again after the event is released.
whenthisspriteclicked — When the sprite is clicked, the script activates.
whenbackdropswitchesto — When the backdrop switches to the one chosen, the script
activates.
when> — When the first value is greater than the second value, the script activates.
whenIreceive — When the broadcast is received, the script activates.
Scratch 3.0 has the following two Event Stack blocks:
broadcast — Sends a broadcast throughout the Scratch program, activating When I Receive
() blocks that are set to that broadcast.
broadcastandwait — Like the Broadcast () block, but pauses the script until all scripts
activated by the broadcast are completed.
Control blocks
Control blocks are the blocks that control scripts. There are 11 Control blocks in Scratch 3.0.
Scratch 3.0 has the following one Control Hat block:
whenIstartasaclone (sprites only) — This hat block is triggered whenever a clone is
created, and will only be run by that clone.
Scratch 3.0 has the following three Control Stack blocks:
waitseconds — Pauses the script for the amount of time.
waituntil — Pauses the script until the condition is true.
createcloneof — Creates the specified clone.
Scratch 3.0 has the following five Control C blocks:
repeat — A loop that repeats the specified amount of times.
forever — A loop that will never end unless the Stop Sign is pressed.
ifthen — Checks the condition so that if the condition is true, the blocks inside it will activate.
ifthenelse
Checks the condition so that if the condition is true, the blocks inside the first C will activate
and if the condition is false, the blocks inside the second C will activate.
repeatuntil — A loop that will stop once the condition is true.
Scratch 3.0 has the following two Control Cap blocks:
stop — Stops the scripts chosen through the drop-down menu. Can also be a stack block
when "other scripts in this sprite" is chosen.
deletethisclone (sprites only) — Deletes a clone.
Sensing blocks
Sensing blocks are the blocks that detect things. There are 21 Sensing blocks in Scratch 3.0.
Scratch 3.0 has the following three Sensing Stack blocks:
askandwait — An input box appears — you type the value in and it stores the value in
the answer variable.
resettimer — Resets the timer.
setdragmode — Sets the sprite to draggable or not draggable.
Scratch 3.0 has the following five Sensing Boolean blocks:
touching? — The condition for checking if the sprite is touching the mouse-pointer or another
sprite.
touchingcolor? — The condition for checking if the sprite is touching a specific color.
coloristouching? — The condition for checking if a color on the sprite is touching a specific
color.
keypressed? — The condition for checking if the specified key is being pressed.
mousedown? — The condition for checking if the mouse is down.
Scratch 3.0 has the following ten Sensing Reporter blocks:
distanceto — The distance from the sprite to the mouse-pointer or another sprite.
answer — The most recent input with the Ask () And Wait block.
mousex — The mouse-pointer's X position.
mousey — The mouse-pointer's Y position.
loudness — How loud the noise is that the microphone is sensing.
timer — How much time has passed since the Scratch program was opened or the timer
reset.
of — The X position, Y position, direction, costume, size or volume of the Stage or a sprite.
current — The specified time unit selected.
dayssince2000 — The number of days since 2000.
username — The username of a user.
Operators blocks
Operators blocks are the blocks that perform math functions and string handling. There are 18
Operators blocks in Scratch 3.0.
Scratch 3.0 has the following seven Operators Boolean blocks:
< — The condition for checking if a value is less than the other.
= — The condition for checking if two values are equal.
> — The condition for checking if a value is greater than the other.
and — True if both conditions are true.
or — True if either condition is true.
not — Makes the condition checked if it is false, not true, or true, not false.
contains? Checks if the first parameter's text contains the second parameter's text — if it
does, the block returns true.
Scratch 3.0 has the following eleven Operators Reporter blocks:
+ — The value of the addition.
- — The value of the subtraction.
* — The value of the multiplication.
/ — The value of the division.
pickrandomto — Picks a random number between the two limits.
join — The two values put right next to each other.
letterof — The specified character of the value.
lengthof — The length of the value.
mod — The remainder of the division.
round — Rounds the value to the nearest whole number.
absof — The absolute value (abs), square root (sqrt), sine (sin), cosine (cos), tangent (tan),
asine (asin), acosine (acos), atangent (atan), natural logarithm (ln), logarithm (log), exponential
function (e^), or base 10 exponential function (10^) of a specified value.
Right-clicking some of the blocks will yield more choices of its type.
Variables blocks
Variables blocks are the blocks that hold variables and lists. There are 5 Variables blocks and
11 list blocks in Scratch 3.0.
Scratch 3.0 has the following four Variables Stack blocks:
setto — Sets the specified variable to the amount.
changeby — Changes the specified variable by the amount.
showvariable — Shows the variable's Stage Monitor.
hidevariable — Hides the variable's Stage Monitor.
Scratch 3.0 has the following Variables Reporter block:
variable — The variable's value.
List blocks are the blocks that manage lists. They are located in the Variables category and
are not found in the bar to the left. There are 11 List blocks in Scratch 3.0.
Scratch 3.0 has the following six List Stack blocks:
addto — Adds an item to the list (the item goes at the bottom of the list of items) with the
specified content in it.
deleteof — Deletes the item of the list.
deleteallof — Deletes all items of the list.
insertatof — Adds an item to the list (the item goes where you specify in the list of items)
with the specified content in it.
replaceitemofwith — Replaces the item's content with the specified content.
showlist — Shows a list.
hidelist — Hides a list.
Scratch 3.0 has the following 4 List Reporter blocks:
list — The list's value.
itemof — The item's value.
lengthof — How many items there are in the specified list.
item#ofin — Reports the index in a list where an item first appears.
Scratch 3.0 has the following List Boolean block:
contains? — The condition for checking if an item's content is the specified text.
My Blocks
My Blocks are user-made custom blocks. There are 4 unique kinds of My Blocks in Scratch
3.0. Scratch 3.0 has the following My Blocks Hat block:
definecustomblock — Defines a custom block.
Scratch 3.0 has the following My Blocks Stack block:
customblock — A custom block.
Scratch 3.0 has the following My Blocks Boolean block:
customboolean — A true/false value.
Scratch 3.0 has the following My Blocks Reporter block:
customreporter — An input for a value, set by the definition My Block.
Grow Tool: This tool allows you to increase the size of your sprite or of whatever you click on
in the paint editor.
Shrink Tool: This tool allows you to decrease the size of your sprite or of whatever you click
on in the paint editor.
Rotate Counter Clockwise Tool: This tool allows you to turn your sprite or whatever is
selected counter clockwise motion.
Rotate Clockwise Tool: This tool allows you to turn your sprite or whatever is selected in a
clockwise motion.
Flip Horizontal: This tool allows you to flip you sprite or a selected part of your sprite
horizontally (Left to Right).
Flip Vertical: This tool allows you to flip your sprite or a selected part of your sprite vertically
(up and Down).
Import Button: This button allows you to import images that you have downloaded from the
internet or add other sprites into you new sprite.
Clear Button: This button will erase everything that you have painted so far. Be careful.
Undo/Redo Buttons: These buttons allow you to undo or redo changes that you have done to
your sprite.
Paint Brush: This tool allows you to paint freely. You can change colors using the Eyedropper
tool or clicking using the Color Swatch located below the toolbar. This tool has varying sizes.
Eraser: This tool allows you to erase drawings you have already made. Like the Paint Brush,
you may change its size in the tool options.
Fill Tool: Fill Tool allows you to click somewhere and have everything of the same color that is
next to your cursor filled in a certain color.
Rectangle Tool: With this tool you may draw filled or unfilled rectangles by dragging a box
with your cursor.
Ellipse Tool: This tool functions the same as the Rectangle Tool except it creates shapes that
are circular or elliptical.
Line Tool: This tool draws lines of your chosen color from the place where you first clicked to
your cursor.
Text Tool: This tool allows you to type text in a variety of fonts.
Selection Tool: This tool allows you to select a region of your picture and move it.
Stamp Tool: This tool allows you to select an area and then copying it by clicking anywhere
else in your image.
Eyedropper Tool: The Eyedropper Tool is used for clicking on a color and then having that
become your selected color.
Tool Options: Some tools have various options available to them, such as change the brush
size for the brush and eraser tools and the fill or empty options available to the rectangle tool.
Color Swatch: This tool allows you to select from a wide variety of colors. Pick your color and
than draw your line.
Color Switcher: This tool allows you to switch between two different colors. Click on the arrow
to switch between the selected colors.