0% found this document useful (0 votes)
20 views77 pages

Programming With Scratch

The document provides an introduction to Scratch, a visual programming language designed for creating interactive projects. It covers the basics of programming, the Scratch interface, and the various types of code blocks used in Scratch. Additionally, it includes exercises to reinforce learning and practical lab work to create simple projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views77 pages

Programming With Scratch

The document provides an introduction to Scratch, a visual programming language designed for creating interactive projects. It covers the basics of programming, the Scratch interface, and the various types of code blocks used in Scratch. Additionally, it includes exercises to reinforce learning and practical lab work to create simple projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 77

Imagine – Program – Share!

Table of Contents
Lessons Pg.No
1. Introduction to Scratch …………………… 1

2. First look at Scratch …………………… 4

3. Blocks Palette …………………… 14


4. Motion Code blocks …………………… 15
5. Looks Code blocks …………………… 20

6. Paint Editor …………………… 26


7. Pen Code blocks …………………… 31

8. Control Code blocks …………………… 35

9. Variables Code blocks …………………… 42

10. Operator Code blocks …………………… 49


11. Sensing Code blocks …………………… 56

12. Sound Code blocks …………………… 62


Lesson 1: Introduction to Scratch

Introduction
A computer is a electronic machine. It is a
wonderful machine. It does many types of work.
But a computer cannot do anything on its own.
We have to instruct a computer to do
something by giving commands.

What is a Program?
A set of instructions or commands that makes the computer to do the work in
step-by-step manner to produce the results we want is called program.

Commands given to the computer must be in proper order and with correct
spellings.

The method of writing commands or instructions is called Syntax. It is the


grammatical rule to instruct a computer.

A programming language is a language which consists of a set of vocabulary and


the syntax of commands.

Some examples of Programming languages are C, C++,


FORTRAN, COBOL etc.

Each computer language has a unique set of words


that is understood by the computer and a
special syntax for organizing instructions.

Why Programming?
Programming is the technique of writing instructions to the computer to achieve a
result.

By learning programming:

 We can understand computers and its way of work.

1
 We can learn the logical and analytical skill.
 It greatly expands our creativity.
 We can learn important problem-solving and design strategies.

Scratch Programming Tool


Scratch is a visual programming environment
with graphical interface.

With Scratch it is easy to create interactive stories,


animations, games, music, and art etc.

Scratch was developed by the Lifelong


Kindergarten group at the MIT Media Lab in 2007.

Scratch’s slogan is Imagine—Program—Share!

With Scratch, we can create interactive stories, games, graphic art work,
experiments, effective education tools such as math quiz, physics simulation,
educational videos and other multimedia projects and animation programs.

The programs created in Scratch are called as Projects.

Scratch helps you to,

1. learn the basics of computer programming.


2. understand the programming concepts, logic, use of variables etc.
3. develop an idea of design process and program development
4. understand testing and debugging.

Scratch is user friendly and easy to learn.

2
Exercise 1

I. Answer the following :

1. What is a program?
2. Define Programming language.
3. What is Scratch?
4. When and by whom was the Scratch programming language developed?
5. What can we do with Scratch?
6. What are the benefits of learning Scratch?
7. What is Scratch’s slogan?

II. Fill in the blanks :

1. Scratch is a …………………. programming language.


2. Programs created in Scratch are called as ……………..
3. Grammatical rules of programming are called ……………
4. Scratch is a programming language with ……………… interface.

III. Say true or false :

1. Scratch is a structured programming language.


2. Scratch’s slogan is Imagine–Program–share.
3. By learning we can learn how to play games.
4. Programming language consists of a set of grammatical rules to create
programs.

IV. Match the following :

A B
1. FORTRAN a) Assembly language
2. Scrach b) High level language
3. 0 and 1 c) Visual interface
4. Mnemonics d) machine language

3
Lesson 2: First look at Scratch
Scratch is a visual programming language with graphical interface.

Getting Started
Scratch is started by

1. clicking on Programs  Scratch (folder)  Scratch (Application


Window)

2. click on the icon of Scratch application on the desktop 

You will get the following Scratch screen.

4
Scratch anatomy
Scratch window is called as Integrated Development Environment (IDE). It
allow us to design, program, and run our projects.

Title Bar, Menu Bar and Tool Bars


Title Bar
Menu Bar Sprite Tool Bar Stage Tool Bar

Title bar :

At the top of the IDE is the Title bar. Iy shows the name of the application to the
left and the Control buttons (Minimize, Maximize and Close) to the right.

Menu Bar :

Below the Title Bar is the Menu Bar. It contains four menus – File, Edit, Share
and Help. Also it contain buttons to set the language, save the project and share
the project on web,

Sprite Tool Bar :

To the right of the Menu Bar is the Sprite Tool Bar. It allows deleting, duplicating,
growing or shrinking a sprite.

Stage Tool Bar :

To the right of the Sprite Tool Bar is the Stage Tool Bar. It allows to change stage
size or open presentation mode.

The interface is roughly divided into three distinct sections.


 Blocks palette
 Script editor
 Stage
5
Blocks palette

To the left side of the interface, is the blocks palette.

The blocks palette contains various commands


called blocks that are used to create a program.
At the top of the palette, these commands are
grouped into eight categories based on the type of
work they perform.
They are Motion, Looks, Sound, Pen, Control,
Sensing, Operators, and Variables.

Each type of block is color-coded so that we can easily identify them in our
scripts.

The center column is divided in to two parts –


 Current Sprite Info
 Script Area.

6
Current Sprite Info

Current Sprite Info shows a sprite's name, its position on stage, direction, etc.

At the top of the Script area are three tabs which shows the properties or
components of a sprite or a stage.

When a sprite is selected it shows – Scripts,


Costumes and sounds, belonging to the sprite.

When the stage is selected it shows – Scripts,


Backgrounds and sounds, belonging to the stage.

Script Area

Script area is a place where we write script or a program.

Script is a set of commands in step wise order given to


the Sprite to do a particular work or action.

A script is a stack of code blocks.

Script is also called a program.

Scripts are created by dragging and dropping code blocks


from the blocks palette to the scripts area by stacking one
below the other.

7
The blocks and their order are very important, as they determine how sprites
interact with each other.

The right column of the interface is


divided into two parts. The top part is
the “stage” where all of the action
takes place.

The bottom part is the sprite list that


contains all the sprites used in the
program.

Stage

The Stage is the background of the project.

Stage too can have scripts, background and


sounds, similar to a sprite.

The Stage is where you see the actions of stories, games, and animations.

Sprites move and interact with one another


on the Stage. The stage currently displays
the default Sprite which is a kitten.

8
The Stage is 480 units wide and 360 units
tall.
It is divided into an x-y grid.

The position of the sprite on the stage is


given by 2 coordinates, "X " and "Y.

The "X position" value determines the


horizontal location of the sprite and the "Y
position" value determines the vertical location or height.

At the center of the stage, the value of X, Y


coordinates is 0,0.

Horizontally X value ranges from 0 to 240


towards right and 0 to -240 towards left.

Vertically, Y position ranges from 0 to180


towards top and 0 to -180 towards down

To find out x-y positions on


the stage, move the mouse
cursor around and look at the mouse x-y
display just below the Stage

The stage can have one or more backgrounds. By default, it is a blank


background.

Like sprites, the stage can have its own scripts and sound effects.

To run a script or to stop a script execution the green and red button
at the top of the stage are used.
9
Scratch runs the projects on the stage by default.

To see a wide screen, run the project in


Presentation Mode.

Presentation Mode is also called full screen


mode.

It can be opened by clicking the presentation mode button, located above of the
stage, in the tool bar.

You can exit Presentation mode either by clicking on the Exit


Presentation Mode icon located in the upper-left corner of the
presentation or by pressing the Escape key.

Sprites are Actors on Stage

Scratch projects are made up of objects called sprites.

A sprite is an image on the stage which performs some


action as per the script.

A sprite is also known as actor.

The default sprite is a cat named as Sprite1. There can be one or more sprites
in a project.

Sprites can be moved around and made to interact with one another.

Each sprite shows different looks. Look of the sprite changes with its action.

Different looks of a sprite is called its costume.

A sprite can have one or more costumes.

Sprites are made to change costume or do action by writing scripts.

Sprites consist of three primary components : Scripts, Costumes, and Sounds.

10
Sprite List

The Sprite List is present below the stage.

It displays the list of all sprites in a project in the form


of small pictures called thumbnails.

The name of each sprite appears below its thumbnail.

To see and edit a sprite's scripts, costumes, and sounds, click on the sprite's
thumbnail in the Sprite List or double-click on the sprite itself on the Stage.

The selected sprite is highlighted and outlined in blue in the Sprite List.
.
Just like sprite, the Stage can have different appearance

Different appearance of stage is called


backgrounds.

To change the backgrounds, scripts, and sounds of


the Stage, click on the Stage icon below the Sprite
List.

Generating New Sprites

New sprites can be added to the program with the New Sprite buttons located
below the stage.

There are three buttons to create a new sprite.

a) Paint New Sprite button starts Scratch’s Paint


Editor program where sprite can be drawn or
edited.

b) Choose New Sprite from File button displays


the New Sprite window, which shows a list of sprites from which we can
select a sprite.

11
c) The Get Surprise Sprite button randomly retrieves one of Scratch’s ready-
made sprites and adds it to your application project.

Basic components of a Scratch Program are Sprites, Costumes, Stage,


Backgrounds, blocks and Scripts.

Scratch programs are saved with an extension .sb

Exercise 2

I. Fill in the blanks :

1. Scratch window is called as …………… ……………… ……………


2. Scratch shows two types tool bars called ……………… and ………………
3. The ………………. consists of groups of instructions.
4. The center column is divided in to two parts –………… and …………...
5. The Scratch programs are saved with an extension ……………
II. Answer the following :

1. How do you start Scratch?


2. In to how many sections, the Scratch window is divided? Name them.
3. How many groups of blocks are there in the blocks palette? Name them.
4. What is script?
5. How are the scripts created?
6. Define Sprite.
7. What are the primary components of a Sprite?
8. Define costume.
9. What does the Sprite list display?
10. What are the primary components of stage?
11. Name the three buttons to create a new sprite?

III. Fill in the blanks by choosing correct answer :


1. Which of the following items are in each Scratch project?
a) Sprite b) Stage c) Script d) All of the above
2. Scratch IDE is divided into …….. sections.
a) two b) three c) four d) five
3. In the blocks palette, the instructions are grouped into ……. categories
based on the type of work they perform
a) two b) four c) six d) eight
12
4. Which of the following is a way to add a new sprite to our project?
a) Paint a new sprite b) Get a surprise sprite
c) Choose a new sprite from file d) All of the above
5. How big is Scratch's stage?
a) 360 x 480 b) 480 x 360 c) 420 x 320 d) 30 x 420
6. What point on the Scratch stage do the coordinates –240, –180 represent?
a) Center stage b) Bottom-left of the stage
c ) Top-right of the stage d) outside the stage

Lab work 1

1. Open Scratch IDE. Do the following :

1. Identify the parts of Scratch IDE.


2. List out different code blocks
3. Open each code block by clicking on it and list out the blocks available in it.

2. Create a Scratch project that makes the kitten meow and say ‘‘Hello
World!’’ when clicked.

1. Start Scratch
2. Change the name of the sprite from ‘Sprite1’ to
‘Cat’ in the Current Sprite Info window and
press Enter key.
3. Click on the Looks button located at the top of the code
block area.
4. Click on the code block labeled ‘say Hello! for 2 secs’
and drag and drop it onto the script area
5. Replace the text ‘‘Hello!’’ with ‘‘Hello World!’’ and press Enter key.
6. To test this, click on the script. You can see the cat displaying the text
“Hello World!’’ in a bubble caption on the stage.
7. To run the program click on the Green Flag Control button
located at the top of the code block area.

13
Lesson 3: Blocks Palette
Every Scratch project contains sprites, costumes, blocks, scripts, and a stage.
To bring the backgrounds and sprites to life, we create scripts.
Scripts are created by dragging and dropping code blocks from the blocks palette
to the scripts area. A stack of connected blocks makes a script which makes the
sprite to perform an action.
Blocks are commands in puzzle-piece shapes that are used to create scripts.

The blocks can be connected to each other as they have a notch at the top and a
projection at the bottom. Each block represents an instruction that tells the sprite
what to do or how to interact with other sprites.

Totally there are 128 different blocks.


The blocks are classified according to (a) their shape or (b) their function.

Types of Blocks based on shape

The blocks are classified into six categories based on their shape. They are,

 Stack blocks
 Hat blocks
 Reporter blocks
 C blocks
 Cap blocks
 Boolean blocks

Stack Blocks :

A Stack block is a rectangular block that is shaped with a


notch at the top and a bump on the bottom to fit above and
below other blocks.

Stack blocks perform the main commands. There are 75 Stack blocks.

Stack blocks are available in every category except Operators block.

14
Hat Blocks :

Hat blocks are the blocks that start every script. They are
shaped with a rounded top and a bump at the bottom.

This is so you can place hat blocks only at the top of the script.

There are 4 Hat blocks, and they are found in the Control category

Reporter Blocks :

Reporter blocks are used to hold numbers and strings.


They are shaped with rounded edges.

There are 26 reporter blocks.

Reporter blocks are used to enter equations, report values, to enter input values
etc.

C Blocks :

C blocks are also known as "Wrap blocks", because they enclose


or warp other blocks within them.

There are 6 C blocks. They are found in the Control block


category.

Cap Blocks :

Cap blocks are the blocks that stop scripts. They are shaped
with a notch at the top and a flat bottom. Cap blocks cannot
be placed at the top of other blocks. They are placed only at
the end of te script.

There are two Cap blocks, and they are found in the Control category.

Boolean Blocks :

Boolean blocks are hexagonal shaped blocks used to test the


conditions — either true or false. There are 13 boolean blocks.

15
Types of Blocks based on function

Blocks can also be grouped on their function. There are eight groups in the
blocks palette. Each group is named based on the function and are displayed in
different colour.

These 8 groups are : Motion block, Looks block, Sound block, Pen block, Control
block, Sensing block, Operator block, and Variable block

 Motion blocks : The motion blocks allow you change the direction of a sprite
and to move it. Motion blocks are colored blue. There are currently 16 motion
blocks.

 Looks blocks : The Looks blocks are used to modify the appearance of sprite
or stage. Looks blocks are colored purple. There are 20 Looks blocks.

 Sound blocks : The Sound blocks are used to control sound and MIDI
functions. Sound blocks are colored pink. There are 13 sound blocks.

 Pen blocks : The Pen blocks are used to control pen and drawing. Pen blocks
are colored mint green. There are 11 pen blocks.

 Control blocks : The control blocks are used to control scripts. Control blocks
are colored gold. There are 16 Control blocks.

 Sensing blocks : The sensing blocks are used to detect things. Sensing
blocks are colored sky blue. There are 17 Sensing blocks.

 Operator blocks : The operator blocks are used to perform mathematical


functions and string handling. Operators blocks are green. There are 17
Operators blocks.

 Variables blocks : The Variable blocks are used to hold values and strings.
Variables blocks are colored orange. There are 5 Variables blocks.

Exercise 3

I. Fill in the blanks:

1. There are ………. blocks in total.


16
2. C blocks are also known as ………… blocks.
3. Cap blocks are the blocks that ……….. scripts.
4. Reporter blocks can hold ……….. and ………………...
5. Stack blocks are available in every category except …………….. block.
6. Boolean blocks are ………… shaped blocks
7. C blocks are found in the ……… block category.

II. Answer the following :

1. Define a block.
2. Define script.
3. What are Stack blocks?
4. What are Hat blocks?
5. Explain Reporter blocks.
6. What is the use of reporter block?
7. Can we use a reporter block directly in a script? Give reason.
8. How many block groups are there based on function? Name them.
9. Why are looks blocks used?
10. What is the use of variable blocks?
11. How are control blocks useful?
12. Which code blocks are used to stop scripts? Where are they found?

III. Match the following :

A B
1. Motion blocks a) sky blue colour
2. Looks blocks b) green colour
3. Sound blocks c) blue colour
4. Pen blocks d) orange colour
5. Control blocks e) pink colour
6. Sensing blocks f) purple colour
7. Number blocks g) gold colour
8. Variable blocks h) mint green colour

Lab work 2

Let's see if we can get our cat moving:

1. In the blocks palette, click on the Control button. Drag When flag clicked
code block to script area.
2. Click on Motion block
3. Click and drag Change x by 10 block and place it below When flag clicked.
17
4. Click on the value 10 and change it to 2.
5. Click on the Looks button.
6. Drag the switch to costume block onto the scripts area.
7. Right click on the drop arrow next costume# and click on costume2
8. Click on Control block and drag wait 1 sec next to switch to costume block.
9. Change the value 1 to 0.5
10. Drag glide 1 secs to x 0 y 0 and change the value of glide to 0.2, x to 50 and
y to –50
11. Click on the sprite or the script to test your work
.

Play with cat

1. Start a new Scratch project.


2. Click on Motion block.
3. Drag move 10 steps and change the value to 60
4. Drag turn 15 degrees and place it below the move 60 steps block.
5. Repeat steps 3 and 4 for 10 times
6. Save your project and run it

18
Lesson 4: Motion Code Blocks
Motion blocks are used to control movement of sprites.

In total, there are 16 motion blocks. They contain 13 Stack


blocks and 3 Reporter blocks.

The motion code blocks, are organized into six sub groups,
each of which is separated by a blank space in the blocks
palette.

The functions of these sub groups are,

 move and rotate sprites


 point sprites in different directions
 change a sprite’s location
 report on a sprite’s position and direction

Moving and Rotating Sprites


There are 3 motion blocks to move or rotate sprites.

They are,

Move () Steps, Turn () Degrees (clockwise), Turn () Degrees (anti-


clockwise).

Move () Steps moves the sprite forward by specified number


of steps.

Turn () Degrees blocks turn the sprite by specified number of


degrees clockwise or counter-clockwise.

.Setting Sprite Direction

There are two motion blocks that are used to point a sprite in a specified
direction. They are Point in direction() and Point towards() blocks.

The Point in direction() block is used to point a sprite to


a particular direction.

19
0 = turns the sprite in the upward direction
90 = turns the sprite in the right direction
–90 = turns the sprite in the left direction
180 = turns the sprite in the downward direction
These values are listed in the block’s drop-down list
or
you can type in an integer value in the range of 0 to 360 in the block.

The Point towards() block points a sprite towards


either the mouse-pointer or another sprite.

Repositioning a Sprite
There are 3 motion blocks that move a sprite to a specific location on the stage.

They are Go to x : () y : (). Go to () and Glide () secs to x : () y : ().

Go to x : () y : (). block is used to move the sprite to the


specified X and Y position.
Go to (). block moves the sprite to the mouse-pointer or another sprite.

Glide () secs to x : () y : () block glides the sprite to the location, for the said amount
of time.

Changing Sprite Co-ordinates

There are 4 motion blocks that changes the location of a sprite on the stage

20
They are,

 Change X by () — Changes the sprite's X position by


the amount.
 Set X to () — Sets the sprite's X position to the
amount.
 Change Y by () — Changes the sprite's Y position by
the amount.
 Set Y to () — Sets the sprite's Y position to the amount.

Bouncing Sprites Around the Stage

If on Edge, Bounce block is used to


bounce the sprite off of the edge
and flip over the sprite's direction
when the sprite comes in contact with the edge of the
screen.

Keeping Track of Sprite Coordinates and Direction

There are 3 motion (reporter) blocks that can be used to display information about X-
position, d Y-position and the direction of the sprite.

They are, X Position — The X position of the sprite.


Y Position — The Y position of the sprite.
Direction — The direction of the sprite.

Exercise 4

I. Fill in the blanks:

1. In total, there are ……….. motion blocks.


2. The motion blocks contain ………………. stack blocks and ………. reporter
blocks.
3. The motion blocks are organized into ………….sub groups
4. The ……………….., block moves the sprite forward in the direction it is
facing.

21
II. Answer the following :

1. What are the functions of Motions blocks?


2. How many stack blocks and reporter blocks are there in motion block?
3. Name the motion blocks that move and rotate sprites.
4. What is the use of the following motion code blocks:
a) point in direction () b) point towards ()
5. Which blocks are used to reposition a sprite?
6. What is the function of if on edge bounce block?
7. Which block glides the sprite to new location?

III. Choose the correct answer and complete the statements.

1. If you tell your sprite to change x by -30 and change y by 10, which of the
following statements best describes the motion of the sprite?
a) 30 pixels right, 10 pixels up b) 30 pixels left, 10 pixels down
c) 10 pixels left, 30 pixels up d) 30 pixels left, 10 pixels up
2. If you specify a value of 90 in the point in direction block, what position
does that represent on the Scratch stage?
a) Up b) Down c) Left d) Right
3. The go to block can do all of the following except:
a) Go to the location of another sprite b) Go to location of the mouse
cursor
c) Go to the location of the current sprite

IV. Match the following :

1. rotate a sprite a) x – position


2. point sprite direction b) go to
3. change sprite’s location c) if on edge bounce
4. report sprite’s position d) turn 90 degree
5. control sprite movement on touching edge e) point towards

Lab work 3

1. Creating the Virtual Fish Tank

1. Open New Scratch Project

2. Right click the Cat Sprite on the stage to delete

22
3. Click on the Image icon under the stage to go to the Backdrops Library and
select an underwater background.

4. Next Click on the New sprite icon under


the stage to select your sprites from the
Scratch Sprite Library.

Click on ‘Choose new sprite from file’ button.

Sprite Library folder opens.

Select ‘Animals’ folder. From that, select ‘fish2’ sprite by double clicking on
it.

In the ‘ Current sprite info’ area, change the name of the sprite to ‘purple’ and
press enter key.

5. Repeat step 4 for two more times, add the following list of sprites to the
application project
Sprite Filename Sprite Application Name
fish3 Yellow
fish4 Spotted
6. Arrange the sprite on your stage by dragging them where you want them to
go.

7. Resize each sprite.

23
8. Next, change the direction of each
fish and add the set rotation style to
left and right.

9. Select the blue fish and drag the code blocks as


given to the script area to move the Blue Fish

10. Go back to each fish and add the script in the same way. Set different values for
each fish.
11. Finally, add sound to your project. Click on the stage. You will add sound
to the stage script. Click on the Sound tab above the Script Blocks to enter
the sound library. Select "effects" bubbles.

12. Save your project and run it by clicking on the green flag.

24
Lesson 5: Looks Code Blocks
Looks blocks are used to control the appearance of sprite and of stage backgrounds.

There are 20 Look blocks. There are 15 Stack blocks and 2


Reporter blocks in this category.

A costume is one out of many appearance or look of a


sprite.

A costume can be edited, created, and deleted, but every


sprite must have at least one costume.

Changing Sprite Costumes


You can change the costume of any sprite you add.
A sprite can have any number of costumes. You can switch
between the costumes at any time.

To change the costume of a sprite,

 select the sprite’s thumbnail


 click on the Costumes tab located at the top of the
scripts area
 click on the Import button. This opens a window
 locate and select a new costume for the sprite.

A sprite can have more than one costume. All costumes are listed in the costume tab..

The code blocks that are used to change the costume of sprite are, Switch to
costume(), next costume, costume#

‘Switch to Costume ()’ changes sprite's costume to


the specified one.

‘Next Costume’ block changes sprite's costume to


the next in the list of costumes.

25
Costume # block display the sprite's current costume number on stage.

Changing a Stage Background


Like sprites, stage can also have different appearances. The appearance of stage is
changed by changing the backgrounds.

To change the background of stage,

 select the stage thumbnail


 click on the Background tab located at the top of the scripts area
 click on the Import button. This opens a window
 locate and select a new background for
the stage.

The blocks that are used to change the background of stage are, Switch to
background(), next background, background#

Switch to background () changes stage’s background


to the specified one.

Next background block changes the stage’s


background to the next in the list of backgrounds.

The background # block display its stage’s current background number on stage

Making Sprites Talk and Think


To make sprites more alive on screen you can make them talk or think.

The say () for () secs, say (), think () for () secs, think () blocks are used to display text
in speech and thought bubbles, making a sprite look like talking or thinking.

These blocks are applicable only to sprites.

26
‘say () for () secs’ block displays text in speech bubbles for specific time.

‘say ()’ block displays text in speech bubbles continuously.

‘think () for () secs’ block display text in thought bubbles for specific time.

‘think ()’ block display text in thought bubbles continuously.

Applying Special Effects to Costumes and Backgrounds

Three looks blocks, Change () Effect by (), Set () Effect to ()


and Clear Graphic Effects are used to apply special
effects to both sprites and the stage.

Change () Effect by (), Set () Effect to () are used to


apply any of the following special effects to a sprite’s costume or to the stage’s
background.

 Color. Modifies the costume or background’s color.


 Fisheye. Magnifies a portion of a costume or background.
 Whirl. Twists and distorts a portion of a costume or background.
 Pixelate. Displays a sprite or background at a lower resolution than the
resolution at which the image was created.
 Mosaic. Creates an image made up of repeated instances of a sprite
or background.
 Brightness. Modifies an image by increasing or decreasing its intensity of
light.
 Ghost. Fades the appearance of a costume or background to make it
look transparent.

clear graphics effect block is used to


clear all graphic effect on sprite or stage .

An example of each of these graphic


effects on a sprite is shown in the figure

27
Changing a Sprite’s Size

Change size by(), Set size to ()% and size() code blocks, are applied only to sprites.
They allow you to change a sprite’s size.

Change size by() block modifies a sprite’s size by


specifying a relative value.

Using this code block, you can slowly increase a


sprite’s size and then reduce its size just as quickly.

Set size to ()% code block lets you set a sprite’s size to a specific percentage of its
current size (larger or smaller).

size() block holds the sprite's size and the size value can be displayed as a
Stage monitor.

Making Sprites Appear and Disappear

Show and Hide code blocks, are used to display or hide a


sprite.

Show and Hide code blocks do not take any input,

Exercise 5

I. Choose the correct answer and complete the statements:

1. The switch to costume block is what kind of block?


a) Motion b) Control c) Looks d) Sensing
2. Which of the following graphical effects splits a sprite into a pattern of
smaller images of itself?
a) Whirl b) Pixelate c) Mosaic
3. What is the significance of the say for block?
a) You can specify how long the speech bubble displays
b) The script stops for the time specified.
c) All of the above.
f) None of the above

28
II. Answer the following:
1. Why do we use Looks code blocks?
2. What is a costume?
3. How do you change the costume of a sprite?
4. State the three blocks used to change the background of a stage.
5. Which blocks are used to make a sprite talk or think?
6. Name the special effects that can be given to a sprite.
7. How do you change the size of a sprite?
8. Does the switch to costume block and the next costume block always achieve
the same result? Justify your answer.

III. Correct the following false statements :

1. A costume is one out of possibly many dresses a sprite can wear.


2. The looks code blocks are used only to change the sprite’s costume.
3. Using the next costume looks block, you can change a sprite’s costume to a
different costume.
4. Brightness fades the appearance of a costume or background to make it
look transparent.
5. The change color effect by code block is applicable only to the sprite.

Lab work 4

1. Make the bat fly

1. Start a new Scratch project. Delete the cat sprite.


2. Click on the Choose Sprite from File button located in the middle of the
new sprite button controls. This will open the New Sprite window.
3. Double-click on the Animals folder, scroll down and select the bat-2a sprite,
and then click on the OK button. Place this
sprite on right side top corner of the stage.
Resize the sprite to small.
4. Next, click on the Import button in the sprites
area and add a costume to the first bat by
clicking on Import  Animals  bat-2b.
5. Write the script given in the script area of first bat.
6. Save your project and run it by clicking on the
green flag.
2. Creating the Dance Party

1. Start a new Scratch project.

29
2. Delete the cat sprite.
3. Select the spotlight-stage from the Indoor
folder.
4. To add the first dancer sprite, click on the
Choose Sprite from File button located in the
middle of the new sprite button controls.
5. Double-click on the People folder, scroll down
and select the cassy-dancing-1 sprite, and
then click on the OK button.
Place this sprite on left side – first spot light – of the stage.
6. Next, click on the Import button in the sprites area and add a costume to
the first dancer by clicking on Import  People  cassy-jumping-3
7. In the same way, add a third costume cassy-jumping-4. Now we have
three costumes for first dancer.
8. Similarly add second dancer dan1, place it in the middle of the stage –
middle spot light – and two more costumes dan2
and dan3.
9. Similarly add third dancer anjuli-1, place it in the
right of the stage – right spot light – and two more
costumes anjuli-2 and anjuli-3.
10. Write the given script to first dancer.
11. Repeat the above script to other two sprites also.
12. Save your project and run it by clicking on the green
flag.

30
Lesson 6: Paint Editor

Paint Editor is a simple image editing environment. It is used to create new sprites or
edit costumes or backgrounds and to apply text, color, and shape to our sprites and
backgrounds.

To start Paint Editor, click on Print new sprite button in the New sprite list,

The following screen comes up.

31
Drawing and Coloring Tools

Paint Editor contains the following tools for drawing and coloring:

 Paintbrush — allows for freehand painting using current foreground color


 Eraser — erase the area you brushed over — works as a brush colored
with the checkered background
 Fill tool — fill areas with color or gradient
 Rectangle tool — draw rectangles or squares — can choose from an
outlined or a filled image
 Ellipse tool — create an ellipse or circle — can choose from an outlined or
a filled image
 Line tool — draw lines
 Eyedropper — select a color that is in the picture, or select a color from
color palette
 Switch colors — switch between the two colors in your palette
 Stamp tool — selects part of the picture and allows you to repeatedly copy it
 Color Palette — select a color
Option Buttons
Some drawing tools contain an additional option
that allows a user to manipulate the tool's size.

These options are found under Paintbrush, Eraser tool, Line Tool, Fill Tool,
Rectangle Tool and Ellipse Tool..

Both Paintbrush and Line Tool use the same brush size —
selecting the brush size in one of the two tools will cause a change
in brush size of the other tool.

32
The brush size for Paintbrush and Line Tool also affects the brush size of Ellipse
and Rectangle Tool.

The brush size of Eraser is independent of the


other given tools.

The Fill Tool shows the fill modes you can make
to an image. It is solid color Vertical gradient,
Horizontal gradient or Circle gradient.

Image Manipulation Tools

The Scratch Paint Editor contains the following tools for manipulating part or the
whole image in the Paint Editor:

 Clear — clears the entire canvas


 Flip horizontally — mirror-reverses whole image or selected part of image
 Flip vertically — reverses whole image or selected part of image upside
down
 Shrink — makes the current image or selected part of image smaller by
10%
 Grow — makes the whole image larger or selected part of the image larger
by 10%
 Rotate clockwise — rotates whole image or selected part of image clockwise
30°
 Rotate counter-clockwise — rotate whole image or selected part of image
counter-clockwise 30°
 Selection tool — selects a portion of the screen for you to move, grow, flip,
delete, or rotate
 Text tool — allows you to add text to your sprite in a separate layer
 Import — import an image file to your editor
33
 Undo — reverses last several actions performed in paint editor.
 Redo — performs last action removed by an undo
 Set costume center — allows the user to
change the center point of the sprite
 Zoom in — make the picture big
 Zoom out — make the picture small

To edit an image.

1) Start Paint Editor


2) Click on Import button to open Import Image window
3) Select the folder and select the image. It opens in Paint Editor.

Or

1) Click on the sprite whose costume is to be edited.


2) Click on Edit button.
3) Image opens in Paint Editor.

Now you can make changes to the image. Click on OK to get these images on the
stage. However, these new costumes or backgrounds will not be saved in the Scratch
image folders.

To save them permanently,

a) right click on the sprite


b) click on export this sprite
c) In the Export sprite window, select the folder in which you want save your
sprite.
d) enter a name for your sprite and click on OK.

Exercise 6

I. Choose the correct answer and complete the statements.

1. If you want to create a text sprite with the Paint Editor, what tool do you
use?
a) Fill tool b) Text tool c) Gradient tool
2. The gradient tool produces what kind of graphical effect?
a) A block of color fades from light to dark shades

34
b) A block of color alternates from light to dark shades like zebra stripes
d) It draws a solid block of color with a dark center

II. Answer the following :

1. What is Paint Editor?


2. How do you start Paint Editor?
3. Name the two groups of tools found in Paint Editor.
4. Which tools show additional options?
5. What is the difference between drawing tools and image manipulating tools?
6. How do you edit an image?
7. What is the use of import button?
8. Write the function of selection tool.

III. Match the following :

1. Paint brush a) creating copies of image


2. Eye dropper b) alternates with two palettes
3. Stamp tool c) free hand painting
4. Switch colors d) centers the sprite in the canvas
5. Set costume center e) selecting colors

IV. Correct the following false statements :

1. A change in brush size also affects the eraser size.


2. Paint Editor is used only to create new sprites.
3. The functions of scale buttons and zoom buttons are same.

V. Complete the analogy :

1. Undo : cancel :: Redo : …….


2. Fill tool : fills color :: Eye dropper : ……
3. Stamp tool : drawing tool :: Text tool : …..
4. Eraser : erases area brushed over :: Clear : …..

Lab work 5

Creating the Drum beat animation

1. Start a new Scratch application.


2. Delete the cat sprite by right clicking “Sprite1”
in Sprite list and selecting “delete” option from
pop-up menu.
35
3. Click on “Paint New Sprite” button from New Sprites options to open the
Paint Editor.
4. Select the ellipse tool with no fill option and
draw a thin and long ellipse in the canvas area.
5. Select the stamp tool to select the entire
ellipse. Copy it and paste it directly below the
original ellipse.
6. Select the line tool and connect the two
ellipses.
7. Select the fill tool to fill the drum head in white
and the cylinder in blue.

8. Select the line tool to create the tuning


legs (in yellow color) and the stand for the
drum.
9. Click OK to get the sprite on the stage
rename it to “drum”
10.Now, again open Paint Editor. Use Line and
Ellipse tools to create a stick boy figure.
11.Use Eye dropper tool to pick a color to create
the drum sticks in the upward direction.
12.Click on OK and change the name of the
sprite “sticks”
13.Select “sticks” sprite and costume tab. Under cotume1 choose “copy”.
14.Now click on edit button of the copied costume.
15.Using eraser tool erase the right arm and stick. Recreate
them in downward direction.
16.Repeat steps 13 to 15 to recreate the left arm and stick.
17.Now click on script tab.
18.Using “Control” and “Looks” blocks create the following script.
When left arrow key pressed
switch to costume costume2
wait 0.2 secs
switch to costume cotume1

19.Now do the same for costume 3 using right arrow to provide animation.
20.Save and test your project

36
Lesson 7: Pen Code Blocks
The Pen code block allow to draw custom lines, shapes,
and other graphics. They can also be used to set the
color, width, and shade used in drawing operations.

There are 11 Pen blocks. There are eleven Stack blocks in


this category.

Clearing the Stage Area

The Clear block is used to clear any


drawing operations that might have
made on the stage.

Anything you draw or stamp on the stage’s current


costume does not actually change the costume.
Therefore, when you clear out any drawing, the costume
that makes up the background remains unchanged.

Drawing with the Pen

This pen works very much like a real pen. When placed in a
down position, it can be used to draw on the stage. When
placed in an up position, drawing ceases.

pen up block is used to stop drawing


pen down block is used draw.

Setting Pen Color

There are three pen code blocks – Set pen color to (), Change pen color by() and Set
pen color to() are used to control the pen color.

Set pen color to () lets you set the color to be used while
drawing.

37
When the swatch is clicked, it displays a color
palette.

You can select the color you want either by


clicking on the color or by moving the pointer,
Once specified, the color you selected is
displayed in the code block’s input area.

Change pen color by() is used to specify the


color to be used when drawing by specifying a number.

The following list show the numbers that you can use to specify a range of commonly
used colors.

0 = red 35 = yellow 130 = blue 175 = pink


20 = orange 70 = green 150 = purple

Changing Pen Shade

The code blocks, Change pen shade by() and Set pen
shade to() are used to control the level of shading
applied while drawing.

The range of values supported by the pen shade is 1 to 100


.

By default, Scratch applies a shading value of 50 when drawing colors. A shade


value of 0 results in a black color. A shade value of 100 results in white.

Working with Different Size Pens

The code blocks, Change pen size by() and Set pen
size to() let you change the size of the pen.

38
Stamping (copying) an Instance of a Costume on the Stage

The last block, Stamp allows you to make copies of the selected
costume of a sprite on the stage.

Exercise 7

I. Choose the correct answer and complete the statements

1. The stamp block does what?


a) Organizes your stamp collection
b) Chases another sprite around the stage
c) Creates copies of the selected sprite
d) Transforms the sprite based on a graphic effect
2. Which of the following effects can you set through the Pen palette?:
a) Color b) Shading c) Size d) All of the above

II. Fill in the blanks:

1. A shade value of 0 results in a ……… color and a shade value of 100 results in
…………. color.
2. The range of values supported by the pen shade is …………….
3. The default shading value for any color is ………..when drawing colors

III. Answer the following :

1. What are the functions of Pen Palette?


2. Write the function of Clear code block.
3. Which code blocks are used to set the pen color?
4. State the difference between set pen color to and set pen color to # blocks.
5. Which code blocks are used to set the pen shade?
6. Which code blocks do you use to set the pen size?
7. What is the function of stamp block?

Lab work 6

1. Drawing square with pencil

1. Start a new Scratch application.


2. Delete the cat sprite.

39
3. Click on “Paint New Sprite” button from New Sprites options to open the
Paint Editor.
4. Select the line tool and draw a pencil.
5. Fill pencil with a color of your choice. Click on OK to get pencil sprite on the
stage.
6. Select the Pencil sprite by clicking on it.
7. In the Scripts area, drag the following code blocks and make changes to
values as shown.

when flag clicked


clear
set pen color to 15
set pen size to 2
pen down
move 50 steps
wait 0.5 secs (repeat these three blocks three more times)
turn 90 degrees

8. Test your project by clicking on flag.

2. Draw a triangle, rectangle just as above.

3. Stamping sprites on stage

1. Start a new Scratch application.


2. Delete the cat sprite.
3. Click on Choose new sprite from file icon in the new sprites list.
4. From the animals folder, select elephant1-a. Click on OK.
5. Resize the sprite to small size.
6. In the Script tab enter the following code by dragging blocks.

when flag clicked


repeat 9
move 70 steps
turn 40 degrees
stamp

7. Save and test your work.

40
Lesson 8: Control Code Blocks
Control blocks are the building blocks
of programming.

There are 16 Control blocks.

There are 4 Hat blocks, 6 C – blocks, 4


Stack blocks and 2 Cap blocks in this
category.

Control blocks are used to :

 start events
 check conditions
 repeating or looping
 pause or halt script execution
 send and receive messages

In Scratch, script can be created with three types of constructs.


 Sequence
 Condition checking
 Repeat or loop

Sequence

In this method only stack blocks are used to create script. This is a simple
method. With this construct the script becomes very lengthy script and is difficult
to create powerful events.

Look at the example code block on the left side. In


this example shown, the sprite is glided to new
location using same set of commands for number of
times.

41
All stack blocks are simple commands. They instruct the sprite to do one simple
action only one time.

For example,

block instructs a sprite to say something.

block instructs a sprite to go to the location of mouse pointer.

Stack blocks alone are not useful when we want to execute a set of commands
selectively or when we want to repeat some commands several times.

By using condition checking and looping methods we can create short and
powerful scripts.

Boolean Expression

Sometimes, we want a statement to be executed only under certain conditions.


Such conditions are defined in terms of ‘Boolean Expressions’.

A Boolean expression is an expression that is either true or false.

In Scratch, any block shaped like an elongated diamond is a Boolean expression.

For example,

it is either true that the mouse button is down or it is false.

it is either true that some number is less than another number or it is


false.

With Boolean expressions we can construct conditions.

A condition is an expression that must be true in order for something to happen.

Conditional statements ask questions about the program state to choose from a
set of different sequences of commands.
Conditional statements have slots for Boolean blocks which evaluate to a true or
a false value and execute if the statement is true.

In Scratch, any block whose label says "if," "while," or "until" is example of
conditional logic
42
Conditional blocks
There are five conditional blocks used to apply conditional
logic in the scripts.

They are, if(), if()… else, wait until(), forever if() and
repeat until() blocks.

If() block

If () block is used to test true or false condition


of an expression. Only if the answer is true,
commands wrapped inside if() block are
executed otherwise nothing will happen.

For example, with ‘if’ we can instruct a sprite to say ‘hello’


only if, say, the user has pressed the mouse button.

if ()… else block

if ()… else block is also used to check a true or false condition of an expression.

If the condition is true, the blocks embedded within if() block are
executed otherwise the blocks embedded within else block are
executed.

For example, with if () … else we can instruct a sprite to say


‘hello’ or ‘goodbye’, depending on whether the user has
pressed the mouse button:

Wait until() block

Wait Until () block is a Control block and a Stack block.


This block pauses its script until the specified condition is true.

Forever if() block

The Forever If () block is a control block and a C block.

43
foreverif () block executes blocks inside it continuously, as long
as the condition is true.

Repeat until() block

Repeat Until () block is a control block and a C block.


Blocks held inside this block will loop until the specified
boolean statement is true,

Loops

Repetition or Looping or Iteration is the repetition of a sequence of commands


continuously for some time.

The control blocks that allow for iteration, are


forever() and repeat() blocks.

Forever() block runs a set of blocks placed inside continuously.

Repeat () block runs the blocks inside for said number of times.

So, the fewer code blocks you use when writing scripts, the more is the
program efficiency.

Nested Blocks

We can also use one conditional or lopping block


within another. This results in very powerful and
complex scripts

For example in the figure on left side, one control block


has been embedded within another

When one or more conditional blocks or looping blocks are inserted with in
another conditional block or looping block, it is called Nested blocks.

Nested blocks are very useful to test multiple conditions or to execute multi tier loops.

44
Endless Loops

Loops are extremely powerful tools, providing the capability to perform repetitive
tasks with ease. However, if loops are not set properly, that is if there are
overlapping or the sequence is not correct, it results
in an endless loop.

An endless loop is a loop that never ends


because of a logical error in the program.

For example, in the code block next, we want to set up a


loop that plays an audio file five times. But since the loop is set to run for a condition “as
long as counter value is greater than 5” by mistake, the loop will not be terminating at
all.

Event Handling

An event is an action like clicking a button on the screen


or pressing a key. These events are to be handled
synchronously with the program flow.

When an event is generated another object may responds to that event. For
example, when ‘Save’ button is clicked it opens a dialog box.

Event handling is controlled by hat blocks which are used to start when an event
occurs.

They are When the flag is clicked, When () Key Pressed, When I receive () and When ()
Clicked.

When the flag is clicked, block starts the script. It is the most
common means of starting an application’s execution.

When () Key Pressed code block starts a script whenever a


specific key on the keyboard is pressed.

When () Clicked code block initiates script execution


whenever the sprite to which it belongs is clicked.

45
When I receive () block starts script execution when a
message is sent by another script.

Sending and Receiving Broadcasts

There are two code blocks that are used to send and receive broadcast messages as a
means of communication.

The two code blocks are Broadcast (), Broadcast () and


wait.

Using Broadcast () code block, you can pass messages to


any script within an application that begins with the hat
code block

The Broadcast() and wait code block, sends a


broadcast message but also waits until other
scripts, which are to execute when the message is
sent, has finished executing.

Using the hat block When I receive (), you can set up a script to execute whenever
a specified message is received.

Pausing Script Execution

Sometimes you need to temporarily halt a script’s


execution for a specified period. The code block Wait ()
Secs is used to add a brief pause to the execution of
scripts.

Terminating Script Execution

The stop script and stop all blocks halt script execution.

Using stop script block, you can halt the execution of the
scripts in which the code block is placed.

Using stop all block, you can halt the execution of the scripts completely.

46
Exercise 8

I. Answer the following :

1. List out the functions of Control Palette blocks.


2. What are the types of programming?
3. Which blocks is used to initiate script execution?
4. What is condition?
5. What is condition checking logic?
6. Name the code block that is used to pause script execution.
7. How many types of control blocks are used to set up loops? Name them.
8. What is the difference between forever and repeat loops?
9. Why are loops used in a program?
10. What is the function of broadcast code block?
11. Name the code blocks used in condition checking.
12. What is meant by nesting conditional logic?
13. What is meant by endless loop?
14. Which control blocks terminate script execution?

II. Choose the correct answer and complete the statements

1. Why do we use a forever block?


a) It adds a permanent block to the script
b) It means the script can’t be changed
c) To execute a set of commands in a continual loop
d) To execute a set of commands while a certain condition exists
2. If you want to loop through a set of blocks for a specific number of times,
which block do you use?
a) Forever b) Repeat c) Broadcast
3. Which of the following blocks does not represent a conditional statement?
a) Move 10 steps b) Forever c) Forever if d) Repeat 10
4. Which of the following blocks is not a Boolean operator?
a) wait b) or c) and d) not
5. We use the broadcast block to do what?
a) To enable one sprite to issue commands to another sprite
b) To say a message on the screen
c) To send a message to the other sprites
d) To initiate a loop
6. How do you copy a script from one sprite to another?
a) Right-click on the script, select duplicate, and drag the script to the
second sprite
47
b) Highlight the script, press Ctrl + C to copy it, and press Ctrl + V to paste
it on the second sprite
c) You can’t copy scripts from one sprite to another

Lab work 7

1. Drawing circle
1. Summary of the Project :
In this exercise you will create a pencil sprite in the Pain Editor. When flag
is clicked the pencil start drawing a circle in the green color..

Method :
1. Start a new Scratch application.
2. Delete the cat sprite.
3. In the Paint editor draw a pencil sprite.
4. In the script area stack the following code blocks.
when flag clicked
clear
set pen color to (select color for your pen by clicking on the color
box and
pen down with the eyedropper)
repeat 360
move 1 steps
wait 0.05 secs
turn 1 degrees
5. Test your work and save.
2. Painting application
1. Summary of the Project : In this exercise you will create a drawing
application where the user can select a color by clicking on the
respective color box. Then the user can draw any drawing using the
mouse.
Method :
1. Start a new Scratch application.
2. Delete the cat sprite.
3. In the Paint editor draw a small square sprite in blue color. Rename it to
colour1.
4. Create a costume of blue sprite and rename it to red.
5. .In the script area stack the following code blocks.

when flag clicked


broadcast blue
48
when colour1 clicked
if costume # = 1
broadcast blue
when colour1 clicked
if costume # = 2
broadcast red

when I receive blue


switch to costume blue
when I receive red
switch to costume red
6. In the Paint editor draw a small plus sign sprite. Rename it to pen.
7. .In the script area stack the following code blocks.
when flag clicked
set pen down to 0
pen up
set pen size to 3
forever
go to mouse pointer
if mouse down and not touching colour
pen down
show
else
pen up
hide

when I receive blue


set pen color to blue
when I receive blue
set pen color to red

8. Test your work and save.

3. Create a project to find the greater of two given numbers.

49
Lesson 9: Variables Code Blocks
Variables play an important role in computer
programming.

A variable is a place holder to store some data used by the


program. It can text or numbers or true / false values.

Every variable has a name, called the variable name. A single


variable can store a data belonging to only one data type.

A variable’s data type indicates what sort of value or the data


the variable stores. For example, ‘b’ and ‘h’ are variables in the
expression ½ * b * h.

The value of a variable changes every time you execute the


program.

Data is any type of information stored in the variable that is used in a program for some
purpose.

Scratch lets you work with a number of different types of data. They are,

 A string is a piece of text data that you hard code within Scratch
applications.
 Boolean data is data that represents a value of either True or False.
 An integer is a numeric value that does not include a decimal point.
 A real number is a number that includes a decimal number.

Assigning Variables to Sprites and the Stage

 Variables may belong to the sprites or to the stage. Therefore, it is important that
when adding new variables to your application, you select the thumbnail for the
sprite (or stage) where the
 variable belongs

Creating Variables

Variables blocks are used create or delete variables.

There are 5 Variables blocks. There are four Stack blocks and
one Reporter block in this category.

50
To create a variable, you must first define and add them to your application projects.

Allows you to create and name a new


variable. When you create a variable,
the blocks for that variable will appear.

Now, Scratch displays the window, allowing you to assign


a name to the variable.

You can choose whether the variable is for all sprites (global) or just for one sprite
(local).

Understanding Variable Scope

Variables are of two types – local or global. A local variable can be used by just one
sprite; and a global variable can be used by all of your sprites in a program.

A variable’s scope identifies the location within an application where the variable’s value
can be modified. Scratch supports two levels of variable scope :

1. Local. Variables can be modified only in the scripts belonging to the sprite in
which the variable is defined.
2. Global. Variables can be modified by any script in an
application.

After a variable is created, the variable block show this set of blocks
set the variable’s initial value or to increment or decrement the
variable value.

Reports value of the variable.

Changes the variable by specified amount.

Sets the variable to specified value.

Shows the variable monitor on the stage.

Hides the variable monitor so it is not visible on the stage.

Deletes a variable and all blocks associated with it.

51
To delete a variable, click on delete variable button in blocks palette. From the
variable list, click on the variable name to delete it.

Assigning Names to Your Variables


Unlike many programming languages, Scratch is very flexible when it comes to naming
variables. You can make variable names as long or as short as you want. Variable
names can include:

 Letters
 Numbers
 Special characters
 Blank spaces
Example

In this example, shown next, a script has been created that


when executed will display the value assigned to a variable
named Counter.

By default, Scratch assigns a default value of zero to all new variables.

For the first time you run the previous script, it counts from 1 to 10. However, if you run
it again, it will count from 11 to 20. You can change this behavior by explicitly assigning
an initial value to the Counter variable.

Creating Lists

A list can store more than one item in it in continuous spaces. A list is identified
by a name like variables. Each item in the list is accessed by a location number.
Lists can store numbers as well as strings of letters and other characters.

Allows you to create and name a new list. When you create a
list, the blocks for that list will appear. You can choose whether the list is for all
sprites (global) or just for one sprite (local).

To create a list, go to the Variables blocks category and click . Once


you make a list, several list blocks will appear..

When you create a list, a list monitor will appear on the stage. A list monitor
shows all the items in a given list. You can type items directly into a list monitor.
52
At first the list will be empty, with length 0. To add to the list, click the + button on
the bottom left of the list monitor. The length will increase by 1. Alternatively, you
can add to the list using the list blocks (e.g., ).

You can resize the list monitor from the bottom right-hand corner.

Deletes the blocks associated with the list.

Reports all the items in the list.

Adds the specified item to the end of the list. The item can be
a number or a string of letters and other characters.

Deletes one or all items from a list. You can choose from the
pull-down menu, or use a number to specify which item to delete. Choosing
?last? deletes the last item in the list. Choosing ?all? deletes everything from the
list. Deleting decreases the length of the list.

Inserts an item at the specified position in the list. You


can choose from the pull-down menu, or use a number to specify where to insert
the item. Choosing ?last? adds the item to the end of the list. Choosing ?any?
inserts at a random place in the list. The length of the list increases by 1.

Replaces an item in the list with the specified


value. You can choose from the pull-down menu, or use a number to specify
which item to replace. Choosing ?last? replaces the last item on the list.
Choosing ?any? replaces a random item in the list. The length of the list does not
change.
Reports the item at the specifed position in the list. You can
choose from the pull-down menu, or use a number to specify which item to
report. Choosing ?any? reports a random item in the list.
Reports how many items are in the list.
Reports true if the list contains the specified item. (The item
must match exactly to report true.)
Strings

Strings are made of letters, words, or other characters (e.g., apple; October
2009; You win!).

53
Strings can be stored in variables or lists(such as or

).
You can join together strings using . You can compare strings using the
following blocks: , , or .
Strings are evaluated as 0 in mathematical operation blocks (such as: )

and in blocks that expect a number (such as and

).

Keyboard input

You can use to prompt a user to type in a response on the


keyboard. The response is stored in . The question appears on the screen
and the program waits until the Enter key is pressed or the check mark is clicked.

is shared by all sprites (global) and is replaced each time


runs. If you want to save the current , you can store it in a variable or list.

Exercise 9

I. Choose correct answer and complete the statements : :

1. If you want to create a variable for a sprite’s exclusive use, which of the
following options do you select when creating the variable?
a) For all sprites b) Not for this sprite
c) For all sprites but this one d) For this sprite only
54
2. We use a counter variable to:
a) Track how many times an event occurs
b) Identify how many sprites we have in the project
c) Select a random item from a list
d) Add a new item to a specific position in the list
3. A variable name can have
a) letters b) numbers c) blank spaces d) all of these

II. Answer the following :

1. Define a variable.
2. Define data.
3. What does the data type indicates?
4. Which data types are supported by Scratch?
5. How can we create a variable?
6. How many types of variables are there? Differentiate them.
7. How do you delete a variable?

III. Fill in the blanks :

1. ……………. Variables are modified only by scripts belonging to the sprite


in which the variable is defined.
2. Variables may belong to the sprites or to the ……….

IV. Match the following :

A B
1. String a) 100
2. Boolean b) 0.5
3. Integer c) you win
4. Real Number d) true or false

Lab work 8

1. Finding factors of a number (factors tree)

1. Summary of the project :

This project demonstrate how one can find the prime factors of any
number, systematically. Any number can be expressed in a product of
prime factors, or in a factor tree.

55
Method :

1. Start a new Scratch application.


2. Create one list, factortree, and three variables: orig, prime, and num.
3. Add the following code block to script area.

when flag clicked


delete all of factortree
ask enter a number and wait
set orig to answer
set prime to 1
forever
if num > prime or num = prime
if num mod prime = 0
add prime to factortree
set num to num / prime
if prime = 1
change prime by 1
else
change prime by 1
else
say join join orig ‘s factor tree = factortree
wai 2 secs
stop script

4. Save and test your project

2. Paddle and ball game

1. Summary of the Project :


In this exercise you will create a Paddle and ball game. When flag is
clicked the ball will be tossing up and down. You can move the paddle
to right or left using arrow keys. Store the user points in a variable.
When the ball hits the paddle, you can increment the score by 1 point.

Method :

1. Start a new Scratch application.


2. Delete the cat sprite.
3. Click on “Paint New Sprite” button from New Sprites options to open the
Paint Editor.
4. Select the line tool and draw a small line. Click on OK
56
5. Rename the sprite to ‘paddle’
6. Create the ‘ball’ sprite in the Paint Editor and click n OK.
7. Create a variable ‘score’ Make it global variable. You can see the variable score
set to 0 on the stage
8. Click on the paddle sprite to select it. In the script area drag the following code
blocks and change the values as given wherever necessary.

when flag clicked


set x to –210
set y to –175
set score to 0

when right arrow key pressed


change x by 10

when left arrow key pressed


change x by –10
9. Click on ball sprite to select it.
10. In the script area, stack the following code blocks.

when flag clicked


set x to 0
set y to 0
point in direction 0
forever
if touching paddle
turn 0 + pick random 1 to 10 degrees
change score by 1
move 10 steps
if on edge, bounce
11. Save your work and test it.

3. Create a project to find the area of rectangle.


4. Create a project to find the greater of three numbers.

57
Lesson 10: Operator Code Blocks
Operator code blocks are green in color. Operator code blocks are used to perform
arithmetic operations and logical comparisons. In addition, operator code block also has
many built-in mathematical functions that can be used in calculations.

Totally there are 17 Operators blocks.

They are grouped in 6 Boolean blocks and 11 Reporter blocks.


It is the only category to contain no Stack blocks

Arithmetic operators

() + (),() – (),() * (),() / () blocks are called


arithmetic operator blocks. They are used to
perform basic arithmetic functions like
addition, subtraction, multiplication and
division.

Order of Precedence

In Scratch complex equations are created by embedding a


series of numbers code blocks within one another.
When a equation or formula is used, Scratch evaluates the expression from left to right
using BODMAS rule and order of precedence.
Order of Precedence is a rule which states that which arithmetic operation should be
performed first in a given mathematical expression.

Hence the order of evaluation of terms in an equation is,


a) terms inside parentheses or brackets
b) exponents and roots
c) multiplication and division
d) addition and subtraction.

Example : The following script evaluates a numeric expression and assigns the result to
a variable named Total.
In the equation ((4 * 8) + (4 – 2)) / 2, multiplication (4 *
5) is performed first and subtraction (4 – 2) next.
Result of these two arithmetic operations are added
next (32) + (2). Resultant value 34 is divided by 2 to
give the total 17.

58
Generating a Random Number

A random number is any number produced or generated from within the given
range of numbers or a random number is one that is drawn from a set of possible
values.

Random numbers are generated by the code block pick


random # to # (where the first # specifies the starting
number in the range and the second # is the ending number in the range).

Random numbers are useful in many applications of everyday science. In computer,


they are used in gaming, gambling and other programs that chance factors..

Comparison (Relational) Operators


Comparison operators are used to compare two or more values.
Since comparison operators relate two or more values they are also
called as Relational operators. There are 3 comparison operators: >, =
and <.

Logical Operators

Logical operators are used to combine two or more


comparison operation to form more complex
combinations. The 3 logical operators are ‘and’, ‘or’ and
‘not’.

Other Operator code blocks

join () () block is used to join two or more words into


a string of words.

letter () of () block returns the letter in the specified


position from the given word.

length of () block returns the number of letters


(including space) in the given word.

() mod () operator block is used to find the remainder of a division.

round () block rounds off the given decimal number to specified digits.

59
Built-in Mathematical Functions

This code block contains 12 different mathematical functions,


which can be selected from the code block’s drop-down list.

Some the functions that are performed by this code block are
;

abs : Returns the absolute, non-negative value of a


number.
Sqrt : Returns the square root of a number.
E^ ; Returns the exponent of a specified value.

Exercise 10

I. Answer the following :

1. What are the uses of Operator code blocks?


2. What is order of precedence? How does Scratch evaluate an equation?
3. What is a random number?
4. With which code block can we generate a random number?
5. What is the use of random number in an application?
6. What is logical comparison? What type of logical operations can be carried out in
Scratch?
7. Which logical operators are used to create combinations of logical comparisons?
8. What type of advanced logical comparisons can be created in Scratch?
9. What is the function of mod operator?
10. How many built-in functions are supported by Operator code block?
11. Write the functions of the following built in math functions :
a) sqrt b) abs c) e^

II. Choose the correct answer and complete the statements :

1. When using the pick a random number block, how can we control what
random number gets selected?
a) Change the beginning number range b) Change the end
range
c) We can’t control which random number gets selected d) All of the
above

60
2. Which of the following mathematical functions does Scratch make
available for use in your scripts:
a) Square root b) Exponents c) Absolute value d) All of the above
3. The mod block:
a) Modifies a number in the list
b) Creates a variable that tracks an interval
c) Transforms the sprite into pixelate form
d) Divides two numbers and returns the remainder

Lab work 9

1. Drawing a polygon

1. Summary of the Project :


In this exercise you will draw a polygon of side 10..

Method :

1. Start a new Scratch application.


2. Delete the cat sprite.
3. Select any other sprite from the folders or create a new one.
4. In the script area stack the following code blocks.

when flag clicked


clear
set pen color to 15
set pen size to 2
pen down
repeat 10
move 50 steps
wait 0.5 secs
turn 360 / 10 degrees
5. Test your work and save.

2. Line puzzle game

1. The goal this project is to connect nine dots using only 4 lines. If the user does he
wins. Otherwise the game will over. The game can be started by clicking on reset
button. You can greet the winner with suitable remarks and screen. When the user
fails display that game is over. You can also display the user how many dots are
connected and how many lines are used to connect them.

61
Method :

1. Start a new project and delete the cat sprite.


2. Create the variables lines used, dots connected, first click, x, and y
3. Create a pen sprite which is small, coloured dot.
4. Add the following codes to pen sprite.

when I receive reset when I receive draw


set pen color to red if first click = 0
set pen size to 5 set first click to 1
pen up go to x1 x y1 y
hide pen down
else
if lines use < 4
change lines used by 1
go to x1 x y1 y
else
if dots connected < 9
broadcast fail

5. Create a black dot (little bigger than pen). Rename it to Dot1. Make a copy to
create another costume of this dot. Change the color of this costume to red.
6. Add the following code to Dot1.

when i receive reset when dot1 clicked


switch to costume black if demoplaying = 0
wait 0.5 secs set x to x position
forever if touching color red? set y to y position
switch to costume red broadcast draw
change dots connected by 1
if lines used = 4 and dots connected = 9
broadcast win
stop script

7. Create other 8 copies of the Dot1 sprite by right clicking on it and selecting
duplicate. Rename all of them as Dot2, Dot3 and so on. Place the dots as
shown in the screen.
8. Create a Reset button sprite at the bottom of the screen.
9. Add this code to Reset button sprite
when reset clicked when flag clicked
broadcast reset broadcast reset

62
10. Create a gameover sprite and add these codes ot its script area.
when i receive reset when i receive fail
hide show
14. Create a win sprite and add these script to it.
when i receive reset when i receive win
hide show
stop script
15. Click on stage thumbnail to select it. In its script area, add the following code
when i receive reset when stage clicked
set dots connected to 0 set x to mouse x
set lines used to 0 set y to mouse y
set first click to 0 broadcast draw
clear

3. Create the following projects in Scratch :


a) To find whether the given number is odd or even
b) To find whether a person is eligible to vote
c) To find whether the given year is leap year

63
Lesson 11: Sensing Code Blocks
Sensing code blocks are used to detect the location or distance between the
sprites, collision of sprites with one another, which key is pressed by the user,
mouse pointer location etc.
There are 17 Sensing blocks. Of that 2 are Stack blocks, 7
are
Boolean blocks and 8 are Reporter blocks.

Collision of Sprites with Other Objects

There are three blocks that determine when a sprite – collides


with another sprite, touches the edge of the screen or other
objects.

The touching() block is used to


determine when a sprite makes
contact with a specified sprite, the
edge of the stage, or the mouse-pointer.

The touching color() block is used to detect when a sprite


makes contact with a specific color on the stage.

The color() is touching () block is used to check if a color on the sprite is touching
another specific color.

Keyboard input

To make our program interactive we can enter data or


information while the program is running. ask() and wait
block prompts the user to type in a response on the
keyboard.

When ask() and wait block is executed, the program waits until you type the
response and press the Enter key or the click check mark.

The response is stored in answer ( ) variable.

Retrieving Mouse Coordinate Status


There are three blocks that control the movement of sprites with
the mouse-pointer.
64
The mouse (X) block returns the location of the mouse-pointer
as it moves along the X-axis. The range of X – axis value is
from –240 to 240.

The mouse (Y) block returns the location of the mouse pointer
as it moves along the Y-axis. The range of ‘Y – axis’ value is
from –180 to 180.

The mouse down? block is used to retrieve a true/false value


that identifies when the mouse’s button is being pressed.
Determining when Keys Are Pressed

The Key () pressed block is used to check if a


specific key is pressed. If the key is being pressed,
the block returns "true"; if it is not, it returns "false"

Determining Distance

The distance to () block is used to find the distance between


one sprite from another sprite or from the mouse-pointer.

Timer blocks

The timer blocks are used to check the time elapsed since the start of application.
The reset timer block resets the timer back to its default value of
zero.

The timer () block returns a number specifying how many


seconds have passed since the timer started running.

Using timer blocks, you can control the pace of animation and the operation of your
applications.

Retrieving Stage and Sprite Data

The x position of sprite code block is used to get information about the sprite or
the stage.

This code block provides easy access to a


number of information like :

 X position
 Y position
65
 Direction
 Costume number
 Size
 Volume

Retrieving Audio Data

The loudness() and loud? blocks allow you to sense sound input from the
computer’s microphone and to use that input within your
applications.

The loudness() block retrieves a number, from 1 to 100,


representing the volume of the computer’s microphone

The loud? block returns a true / false value, depending on whether a sound value
of 30 or greater is detected through the computer’s microphone.

Exercise 11

I. Choose the correct answer and complete the statement:

1. The block after the timer blocks are used :


a) control sprite collision b) change sprite direction
c) to retrieve sprite and stage information d) change value of timer
2. The collision detection blocks are useful in ….. applications
a) games b) drawing c) playing sound d) all of the above

II. Answer the following :

1. What are sensing code blocks?


2. Which blocks are used to determine the mouse pointer location and status?
3. What is the function of key # pressed block?
4. Which code blocks are used to detect the collision of sprites? Write the function
of each of them.
5. State the function of distance to block.
6. Which block is used control the pace of animation and the operation of
applications?

III. Fill in the blanks:

1. There are …….. groups of code blocks in Sensing code block.


2. The …………….. code block resets the timer back to its default value of zero.
66
3. The ……….... code block retrieves the location of the mouse-pointer as it moves
along the X-axis.
4. The ……….. block is used to retrieve a true/false value that identifies when the
mouse’s button is being pressed
.
IV. Write the functions of the following blocks:

1. touching color 2. reset timer 3. key # pressed 4. distance to 5.


mouse down?

Lab work 10

1. Create a Maze game

1. The user controls the main character, the red car, through the
maze using the arrow keys. The car is not able to move through
the maze walls. The car needs to pick up the Wizard Hat and
the Key before it is allowed to move through the door at the
upper right of the maze.

Method :

1. Use the paint tool to create a maze as a background as shown. Make sure all
of the paths are large enough for your main character to move through. Just
use a single color.
2. Import a car sprite. Resize it.

Set the rotation property of the Sprite to None. Write code so that the car can
move up, down, left, and right. Write the initialization code to specify where the
car starts in the maze.

when flag clicked


go to front
go to x1 –189 y1 –130
When any of the arrow keys are pressed, the car moves in that direction. We can detect
which side of the car is touching the wall by painting a different color outline around the
four sides of the car. When a particular side of the car touches the wall of the maze, the
maze senses the color and the car can not move through it.

when up arrow key pressed when down arrow key pressed


point in direction 0 point in direction 180
if not color green is touching purple if not color red is touching
purple

67
move 5 steps move 5 steps

when right arrow key pressed when left arrow key pressed
point in direction 90 point in direction –90
if not color pink is touching purple if not color blue is touching
purple
move 5 steps move 5 steps

3. Create objects to be picked up – A Wizard Hat and a Key Place these objects
in different locations in the maze. Write initialization code so the objects
appear in good places with a good size.

4. Create three global variables – have hat, have key, ans

5. Add this code to Wizard Hat sprite.

when flag clicked if touching car?


go to x1 –52 y1 18 set have hat to 1
set size to 21 % hide
show forever goto x: x position of car y: y position of
car + 10
else
repeat until touching car set have hat to 0
say pick me up! for 0.5 secs
wait 1 secs when I receive you win
set have hat to 0 hide
wait until touching car? when I receive you lost
hide

5. Similarly write code for key

when flag clicked if touching car?


go to x1 163 y1 –123 set have key to 1
set size to 21 % hide
show forever goto x1 x position of car y1 y position
of
car + 10
else
repeat until touching car set have key to 0
say pick me up! for 0.5 secs
wait 1 secs when I receive you win
set have key to 0 hide
wait until touching car? when I receive you lost
hide

68
6. To get to the next level, the car has to go through the door. 7. Make a door
Sprite and place it in a good location in the maze. We want the door to detect
when the car touches it.

when flag clicked if ans =1 and have hat = 1 and have key = 1
go to x1 210 y1 102 broadcast you win
show else
wait until touching car? broadcast you lost
set ans to 1
when I receive you win
hide
when I receive you lost
hide

8. When the car touches the door, the backgrounds should change with
appropriate message..
9. Create two more backgrounds – one to show win message and the other to
show lost message. Rename them as ‘win’ and ‘ lost’. Add the following code
to the stage

when flag clicked when i receive you win


switch to background maze1 switch to background win
set ans to 0 stop script
set have hat to 0
set have key to 0 when i receive you lost
switch to background lost
stop script

10. Save your work and test the project.

69
Lesson 12: Sound Code Blocks
Applications like computer games, uses sound as a means of conveying meaning and
excitement.

Through the addition of background music and sound


effects, applications can really come alive.

Sound code blocks are used to add sound effects and


control sounds.

Playing Sounds
These code blocks allow to play or stop the playback of
MP3 and wave files in your applications.

There are 13 Sound blocks. There are eleven Stack


blocks and two Reporter blocks in this category

 Play Sound () — Plays a sound without pausing the script.


 Play Sound () Until Done — Plays a sound and pauses the script until it
finishes.
 Stop All Sounds — Stops all playing sounds.
 Play Drum () for () Beats — Plays the specified drum for the amount of
beats.
 Rest for () Beats — Pauses the script for the amount of time.
 Play Note () for () Beats — Plays the note for the amount of beats.
 Set Instrument to () — Sets the instrument to the specified one.
 Change Volume by () — Changes the volume by the amount.
 Set Volume to () % — Sets the volume to the amount.
 Change Tempo by () — Changes the tempo by the amount.
 Set Tempo to () bpm — Sets the tempo to the amount.
70
Scratch has the following two Sound Reporter blocks:

 Volume — The volume.


 Tempo — The tempo.

Play sound and Play sound() until done code blocks let
you play any MP3 or wave file in a Scratch project.

Stop all sounds code block stops running of all audio


files belonging to a sprite.

In order to play an audio file,

a) selecting the stage or a sprite from the sprite list


b) click on the Sounds tab location at the top of the scripts area
c) select a sound
s) click on the Import button.

Once the file is imported, you can play the audio file using a script belonging to the
stage or sprite.

Play a Drum
Using the two code blocks shown, you can add the playing of a drum to your Scratch
application and, when necessary, pause drum play for a specifi ed number of beats.

The Play Drum () for () Beats block is a music block and


a stack block. The block will play the specified
instrument for the specified amount of seconds

The Rest for () Beats block is a music block and a stack block. The block pauses
its script for the specified amount of beats.

Playing Musical Notes

In addition to playing audio files and different types of drum beats, Scratch lets you play
musical notes with various instruments using the sound code blocks.

The Play Note () for () Beats block play the specified


note with a set MIDI instrument for the specified
amount of beats.

71
You can specify a note either by typing it into the code block’s first input box or by
clicking on the drop-down list located inside the code block’s input field, which displays
a graphic representation of a piano keyboard.

Using this keyboard, you can select a note by clicking


on one of the keyboard keys. The range of available
notes is from 0 to 127, with 60 representing the
middle C note.

The Set Instrument to () block changes the instrument that the Play Note () for ()
Beatsblock will play.

It supports a total of 128 different instruments, numbered 1 to 128. You can select an
instrument by keying its number into the block’s input field or by selecting an instrument
from the block’s drop-down list.

Configuring Audio Volume


These sound code blocks are used to change or set the volume at which audio files,
drum beats, and musical notes are played.

Change volume by() code block is used to change the


volume of sound playback for an individual sprite.

Using this code block, you can change a sprite’s volume


by a specified percentage, with 0 being no volume and
100 being the maximum volume.

Set volume to() code block lets you assign a specific value to a sprite in the range of 0
to 100.

Using the third code block, you can retrieve a sprite’s volume and optionally display this
value in a monitor on the stage.

Setting and Changing Tempo

The last three looks blocks are used to set, change, and
report on the tempo at which drum beats and musical notes
are played.

Change tempo by () code block changes the tempo used to play a drum or note.
Tempo is a measurement of the speed, in beats per minute, at which a drum or note is
played. The larger the tempo value, the faster the drum or note is played.
72
Volume is the loudness of the sound and tempo is the pace of the sound.

Set temp to () code block lets you set the tempo used to play a drum or note to a
specific number of beats per second.

Using tempo () code block, you can display a sprite’s currently assigned tempo
and optionally display this value in a monitor on the stage.

Exercise 12

I. Answer the following :

1. What is the function of playing sounds code block?


2. How is an audio file played?
3. State the function of play a drum code block.
4. Which code blocks are used to play musical notes? State the function of
each of them.
5. Name the code blocks that are used to configure audio volume.
6. Which code blocks are used to change the tempo of sounds?
7. What is tempo?
8. State the difference between the volume and the tempo.

II. Fill in the blanks:

9. There are …….. groups of code blocks in Sound code block.


10. Play a drum code block lets you choose from among ……. different types
of drums.
11. The second code block in the playing musical note group, supports a total
of …… different instruments
12. Using ‘Change volume by’ code block, you can change a sprite’s volume
by a specified percentage, with 0 being …………. and 100 being the
……….. volume.
.
III. Choose the correct answer and complete the statement:

1. In order to play an instrument you need to accompany the set instrument


to block with a:
a) play sound until done block b) play drum block
c) play note block d) change volume to block
2. Which of the following resources can you use to import a sound into your
project?
a) Scratch's built-in sound library b) Your personal MP3
73
collection
c) A third-party sound download site d) All of the above
IV. Correct the following false statements :

1. Tempo is the loudness of the sound.


2. An audio file can be played without adding to a sprite or stage.
3. There is no need of scripts to play sound.

Lab work 11

1. Creating a drummer application

1. In this exercise you will create a drummer


application. When flag is clicked the drums
start beating which is indicated by color
change. As the temp goes the lamps will turn
on and off and there will be little animation of
other sprites.

Method :

1. Start new Scratch application


2. Delete the cat sprite.
3. Create new sprites as shown below.
4. Make Variable "Tempo"
5. Create Tracer Sprite (One Vertical Line).
6. Add these scripts to Tracer sprite.

when flag clicked


forever
move temp / 10 steps
if x position > 235
set x to –235

7. Import Drum2 Image from things folder.


8. Click on copy button next to costume
name and make a copy of drum2 sprite.
9. Edit it in the Paint editor by adding red
paint on drum head. Click on OK.
Rename it to drum3.
10. Add these scripts to drum2 sprite.

74
when flag clicked when flag clicked
forever forever if touching tracer?
if touching tracer? play drum 36 for 0.2 secs
Switch to costume drum3 wait until not touching tracer?
else
Switch to costume drum2

11. Right click on drum2 sprite in sprite list area and click duplicate to make 2
more copies. Place these drums in the positions shown in figure.
12. Similarly import ‘lamp’ sprite. Make a copy of it. Edit it in Paint editor by
adding yellow shade to lamp head to give a lighting effect. Rename it to
lamp2.
13. Add this script to all lamp sprite.

when flag clicked when flag clicked


forever forever if touching tracer?
if touching tracer? play drum 42 for 0.2 secs
Switch to costume lamp2 wait until not touching tracer?
else
Switch to costume lamp
11. Make 8 copies of lamp sprite by right clicking on it and position them as shown

12. Similarly import ‘cheasy puffs’ sprite. Make a copy of it. Edit it in Paint editor to
make it distorted. Rename it to cheasy puffs2.

13. Add this script to all cheasy puffs’ sprites

when flag clicked when flag clicked


forever forever if touching tracer?
if touching tracer? play drum 29 for 0.2 secs
Switch to costume cheasy puffs2 wait until not touching tracer?
else
Switch to costume cheasy puffs

14. Make 2 copies of cheasy puffs sprite by right clicking on the sprite and
position them as shown.
15. Click on stage sprite. Click on import button Select pop sound. Click on OK to
add it to stage sprite.
16. Save, test and enjoy your program !

75

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy