Block Programming - Full
Block Programming - Full
2
BLOCK PROGRAMMING
SCRATCH ENVIRONMENT
4
Basic Concept of Scratch
5
Stage and sprites
◼ You can create New sprites and find the sprites from the Sprite List
7
Current Sprite Info
◼ You can find the sprite’s name, position, direction, lock state, pen color
and rotation style
8
Toolbar
9
Costume
10
10
Costumes
11
12
12
Scripts Area
13
Overall Scratch Program
Tabs
14
The LOOKS script
15
The WAIT instruction
16
16
EVENT Script
◼ Drag this block out, and snap it on top of the blocks you already have in
17
your script.
◼ Now, instead of having to double click on block of code, we can just click
on the flag icon to play the animation.
17
Exercise #1
18
Exercise #2
19
Exercise #3
◼ Set the sprite to say “I want to go shopping, lets change” for 4 secs
◼ Change to costume A
◼ Then think “Next..” for 4 seconds Draw flowchart based o
n the changes of the scr
◼ Change to costume B atch looks using draw.io
◼ Then think “Next..” for 4 seconds
◼ Change to costume C
◼ Then think “Perfect !!” for 2 seconds
Write the script in Scratch and
see what happen 20
!!
20
Sound
21
Try: Using the Sound block
22
22
Scratch Sound Library
◼ Click on the sprite you want to have sound.
◼ Click on the Sounds tab and select the Speaker icon.
◼ You will see different
categories of sounds that
you can use in your
animation that are
available for you in
the Scratch library.
23
Adding The Sound To Your Animation
24
Adding Sound
25
Recording a Sound
◼ Click on the
record button to
record a sound
◼ Click on the red
button to start
recording
◼ Click on the
square to stop
◼ You can rename
the sound by
typing over the
name
26
MOTION
The MOTION script
How to locate and orient a sprite; position and angle; moving a
sprite
27
Position on the stage
28
Other instructions
◼goto x,y
◼glide to x,y Edit in some coordinate
values and double click t
◼Move N steps
o see where your sprites
goes.
◼Set direction
29
SENSING
The MOTION script
How to locate and orient a sprite; position and angle; moving a
sprite
30
Sensing block code
31
32
32
Sensing block code
◼ Usually used
with conditional The light blue block
has to be inserted
structured in from ‘Sensing’ block
the control
block code
33
Control Script: Conditional Statement
34
34
Exercise #2
35
DATA & VARIABLES
36
36
Computer Memory
◼ A computer program needs to store all the information it is working with in the
computers RAM. It does this using memory addresses, these addresses are
numbers and because a computer is very good with numbers, this is fast and
efficient.
◼ Humans are not good at remembering lots of number (How many phone numbers
can you remember without using your mobile?).
◼ So to help humans, high level languages use variables to name the addresses.
37
Variables
These are storage locations in RAM, controlled by the programming language.
What types of data might we need to use with our programs?
The main ones we will be using are
Numeric (numbers)
◼ is used for calculations.
◼ If you need to use a piece of data in a calculation you should use a numeric
variable.
String(text)
◼ These are normally letters and other non numeric characters.
38
Scratch Variables
The scratch language is able to work out the type of variable we are
using and as a result it only has the one type of variable
39
Scratch Variables
My example variable is
‘Lives’
40
Displaying Variable
41
Displaying Variable
42
Concatenation (Join)
◼ Programmers often require to join two or more strings of text together, this is
called concatenation. It is most often used when displaying text but can also be
used at other times.
For Example The text string
“Hello Bob Roberts”
can also be written as
“Hello” & “ “ & “Bob” & “ “ & “Roberts”
43
More than one variable
◼ Programs can make use of lots of variables. Just make a new variable
in the variable tab
◼ Programmers use sensible names to keep track of what variable does
what.
◼ Answer only stores one value at a time so remember to set a variable
to answer after using ask.
◼ Remember the sequence of a program is very important, so make
sure you think about what you want the program to do.
44
An example of two variables
46
Operators
◼ Operators blocks are the blocks
that perform math functions and
string handling.
◼ These are some of the examples
47
Exercise 2
48
Challenge yourself