KEMBAR78
5.advanced Scripts in Scratch | PDF | Scratch (Programming Language) | Cursor (User Interface)
0% found this document useful (0 votes)
204 views36 pages

5.advanced Scripts in Scratch

Uploaded by

shewaledipa2210
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
204 views36 pages

5.advanced Scripts in Scratch

Uploaded by

shewaledipa2210
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Scratch

Table of contents
Creating Drawing
and
1 2 3 painting
accustom
AdvancedScripts in sprite and tools
Scratch backdrop

4 Creating a 5 6 Applying
costume or a Changing the image effects
sprite size of a on a sprite
sprite
Table of contents
Accepting
Using Inputs from
7 8 Sound 9 the User
Using Control Blocks Sensing blocks
blocks

10 Position 11 Using 12 Creating


oaf Variable variables
Sprite Blocks
1
Advanced
Scripts in
Scratch
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.
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....
2
Creating
accustom
sprite and
back drop....
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 Sprite gallery
editor. Here, you can draw your
sprite using the drawing and painting
tools.

Follow the image..


Create anything
with scratch
Show your creativity ....
3
Drawing and
painting
tools...
 Select:  Circle :
The Select tool is used to select an are a
on the canvas and re locate ,stretcher The circle tool is used to draw ovals or
compress it or modify it.
 Reshape :
Tools perfect circles.
 Rectangle:

This tool is used for bending or changing the The rectangle tool is used to create
shapes of a sprite. rectangles .Click and drag the mouse to
draw a rectangle.
 Brush :  Eraser :
The Brush tool is used for free hand drawing The eraser tool is used to remove (or erase)
by clicking on and dragging the mouse a part of the drawing.
pointer. You can change the colour and size
of the brush.
 Fill :  Text :

The paint bucket or fill tool is used to fill The text tool is used to type letters and
colours only in closed objects. You cannot fill numbers on to the canvas .to type, click
the background with the paint bucket. 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.
Costume 1

Costume 2 4
Costume 3

Creating aces
tome for
sprite...
● 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.
Changing the size of as prate makes it
bigger or smaller. You can change the
5
size of as prate by using the 'set size
'block in the Looks category. You can
use this feature to show a growing or
Changing the
shrinking sprite in an animation
origami. There are two blocks
size of a
available for this, 'set size ’and
‘change size’ .Set size will set the
sprite
sprite to a specific size ,while change
size will change its sizably specific
amount
Control blocks are used to 6
control the way scripts
execute. Scratch 3 has the Using
following basic Control
blocks.
Control
blocks
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.
.

We know that sound can be played by


using Sound blocks in Scratch. The blocks
available in this category can be used to
7
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
Using
volume each time.
SoundBlocks
Note that before executing the above script once
again,. you need to run the block to set the
volume to its full value.
We can add new sounds by using the following options Uploadsound
Surprise
•Upload Sound – to uploada soundfile
that is stored on your computer. Record

•Surprise – to add arandom soundfile Choose a sound

from the library.


•Record – to record your own sound
• Choose a sound –to choose a
sound from the library
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.
Let use the different image effects on a sprite.
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.
.
.

7
Position of a Sprite
X and Y co-ordinates
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- origi
axis. The ’ x’ position determines the horizontal
location of the sprite and ‘y’ position
determines the vertical location of the sprite.
The point
CREDITS: at which
This presentation thewasXcreated
template andbyY-axis
Slidesgo, andmeet
includesis
icons
called the origin. The value of x and y at origin
by Flaticon, and infographics & images by Freepik

is zero.
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 x-y
CREDITS: This presentation template was created by Slidesgo, and includes icons
the sprite
by Flaticon,moves down
and infographics from
& images by Freepik the

origin.
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.
CREDITS: This presentation template was created by Slidesgo, and includes icons
by Flaticon, and infographics & images by Freepik
.
.

While creating scripts or programs,


we often need to use variables to
8
store values. A variable is a
placeholder for some value, similar
to the x and y variables in Algebra. Using Variable
In Scratch, variables can be
uniquely labelled by you. They can Blocks
be used by just one sprite or by all
of your sprites.
.
.

9
Creating variables
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.

You might also like