The document provides an overview of advanced scripting concepts in Scratch, including:
1. Creating sprites and backdrops using drawing tools and costumes.
2. Using control blocks like repeat and forever to execute scripts repetitively.
3. Accepting user input through sensing blocks and displaying it with variables.
4. Positioning sprites using x and y coordinates and ensuring they bounce on screen edges.
5. Storing numeric values with variable blocks for use in scripts.
3. Table of contents
7 8
11
9
12
Using
Sound
Blocks
Accepting
Inputs from
the User
Sensing
blocks
Position
oaf
Sprite
Using
Variable
Blocks
Creating
variables
Using Control
blocks
10
5. What is Scratch ??
JavaScript-based codebase made up of
multiple components such as "Scratch-GUI,"
now based on a library from Blackly,
"Scratch-VM," which interprets code, and
"Scratch-Render," the rendering engine. The
Scratch Blocks are made using Blackly.
6. Advanced Scripts in Scratch
You have already learnt to animate sprite
using the Motion, Looks and Sound blocks
in Scratch. You have also learnt to add
sprite ,delete aspriteand control the position
of sprites.
Let’s see the working of the following script
to recall some of the script blocks....
8. You can draw your own sprites
(pictures or text) using the
Scratch Paint editor.
Sprite
Click the Paint option in the ‘Sprite’
section to open the Scratch Paint
editor. Here, you can draw your
sprite using the drawing and
painting tools.
Follow the image..
Sprite gallery
11. Tools
Select:
The Select tool is used to select an are a
on the canvas and re locate ,stretcher
compress it or modify it.
Circle :
The circle tool is used to draw ovals or
perfect circles.
Reshape :
This tool is used for bending or changing the
shapes of a sprite.
Rectangle:
The rectangle tool is used to create
rectangles .Click and drag the mouse to
draw a rectangle.
Brush :
The Brush tool is used for free hand drawing
by clicking on and dragging the mouse
pointer. You can change the colour and size
of the brush.
Eraser :
The eraser tool is used to remove (or erase)
a part of the drawing.
Fill :
The paint bucket or fill tool is used to fill
colours only in closed objects. You cannot fill
the background with the paint bucket.
Text :
The text tool is used to type letters and
numbers on to the canvas .to type, click
anywhere on the canvas and start typing
when cursor appears
Line :
The line tool is used for drawing lines. To
draw line, press and hold the left mouse
button at the starting point ,then drag and
release I tat
Then ding point.
14. ● You can then use an aback drop
for you scratch project.
● The Looks category has blocks,
using which you can set or
change the backdrop.
● The given script can be used to
display a different back drop
one by one, from the list of back
drops.
15.
16. Changing
the size of a
sprite
5
Changing the size of as prate makes it
bigger or smaller. You can change the
size of as prate by using the 'set size
'block in the Looks category. You can
use this feature to show a growing or
shrinking sprite in an animation
origami. There are two blocks
available for this, 'set size ’and
‘change size’ .Set size will set the
sprite to a specific size ,while change
size will change its sizably specific
amount
19. The script held inside this block will be
executed in a loop for a specified number
of times, before allowing the remaining
script to continue. This block can be used
to execute the same script repeatedly.
For example, in the adjacent script, the
repeat block is used to change the
costume of the sprite after every 5
seconds. It will repeat this 10 times before
coming to a stop.
20. Using
SoundBlocks
7
.
We know that sound can be played by
using Sound blocks in Scratch. The blocks
available in this category can be used to
control the volume, tempo and other
features of the sound being played.
Sounds can be added in Scratch by
importing sound files or recording a new
sound.
The given script will play the sound ‘Meow’
5 times, and gradually decrease the
volume each time.
21. .
Note that before executing the above script once
again, you need to run the block to set the
volume to its full value.
Uploadsound
Surprise
Record
Choose a sound
We can add new sounds by using the following options
•Upload Sound – to uploada soundfile
that is stored on your computer.
•Surprise – to add arandom soundfile
from the library.
•Record – to record your own sound
• Choose a sound –to choose a
sound from the library
22. Let use the different image effects on a sprite.
backdrops. You also learnt how to execute
scripts repetitively using control blocks and
applied special effects to sprites.
Let’s see the following script and recall
some of the blocks that we have used.
Assuming that the given script is created
for the Ballerina sprite, the output will show
the dancing Ballerina.
23.
24. .
O9:Accepting Inputs from the User Sensing blocks
This category contains the blocks that are used to
accept inputs from the user/ keyboard.
It displays an input box and prompts the user to type
the input.
The input entered by the user is stored in the
variable. Let’s see the following script using the
Sensing blocks.
When the green flag is clicked, the sprite will ask for
‘What’s your name?’ and wait for an answer. Once the
user enters an answer and clicks on the blue check
mark, the sprite will display the entered name for 5
seconds.
27. CREDITS: This presentation template was created by Slidesgo, and
includes icons by Flaticon, and infographics & images by Freepik
The stage in Scratch can be divided into four
squares using a horizontal and a vertical line.
The four squares thus formed are called
quadrants. The horizontal line represents the
X-axis and the vertical line represents the Y-
axis. The ’ x’ position determines the horizontal
location of the sprite and ‘y’ position
determines the vertical location of the sprite.
The point at which the X and Y-axis meet is
called the origin. The value of x and y at origin
is zero.
origi
28. CREDITS: This presentation template was created by Slidesgo, and
includes icons by Flaticon, and infographics & images by Freepik
The value of x position of a sprite
increases from 0 to 240 when it
moves to the right from the origin and
decreases from 0 to -240 when the
sprite moves to the left from the
origin. Similarly, the value of y
position of a sprite increases from 0
to 180 when it moves up from origin
and it decreases from 0 to -180 when
the sprite moves down from the
origin.
x-y
29. You Can Show The Above Background On The Stage By Adding The Xy-grid From
The List Of Backdrops. The Position Of A Sprite On The Stage Is Decided By The
Values Of Its X And Y Coordinates.
If On Edge, Bounce
While Moving A Sprite On The Stage It Can Happen That The Sprite Might Go
Beyond The Boundaries Of The Stage And Disappear. To Avoid This, We Can Use
The If On Edge, Bounce Block.
This Block Checks To See If The Sprite Is Touching The Edges Of The Stage, And If
It Does, It Will Make The Sprite Turn Back In The Opposite Direction.
In The Following Script, The Fish Moves 10 Steps And Waits For 0.05 Seconds.
When It Reaches The Edge Of The Stage, It Will Change Its Direction Instead Of
Going Beyond The Stage Boundary.
Note That The Set Rotation Style Left-right Block Has Been Added To Avoid The
Sprite From Rotating Vertically.
30. CREDITS: This presentation template was created by Slidesgo, and
includes icons by Flaticon, and infographics & images by Freepik
31. 8
.
Using Variable
Blocks
.
While creating scripts or programs,
we often need to use variables to
store values. A variable is a
placeholder for some value, similar
to the x and y variables in Algebra.
In Scratch, variables can be
uniquely labelled by you. They can
be used by just one sprite or by all
of your sprites.
34. .
Step 1: Select the Variable block.
Step 2: Click on Make a variable.
Step 3: Specify the name of the variable and click
OK.
Step 4: The name of the new variable appears with
a check box before it. You can now see the blocks
associated with the variable.