Starting With Scratch is a block-based programming course provided by the CodeTigers and STEM Impressionists Program collaboration. Over the course of 10 weeks, students will practice programming on Scratch while simultaneously learning fundamental computer science concepts. Each week will be taught by two student mentors who will walk participants through different lessons that will overtime build their understanding of coding through the Scratch platform. Throughout the course, students will be provided with resources to further their exploration of computer science in addition to preparing them to continue on to other coding platforms such as Python, micro:bit, and HTML/CSS. YouTube class: https://www.youtube.com/watch?
2. Coolest Projects Competition
Registration is OPEN!
You can register to share your
creations in Raspberry Pi's
world-leading online tech showcase!
Raspberry Pi welcomes projects
from anywhere in the world,
whatever your experience level!
18. The boy
wonders what
he is going to
do for the day.
You, as the
player, decide
what the boy is
going to do
The story ends.. or
the player goes
back for another
ending!
19. Most of the time, stories are singular with one
But in adventure stories, the player
gets to create the journey!
, and
21. The boy wonders what he
is going to do for the day.
You, as the player, decide
what the boy is going to do
The story ends.. or the
player goes back for
another ending!
1. Create story ending backdrop!
1. Create your sprites or get them
from our backpack materials!
2. Bring the the boy sprite into the
room and ask the question:
“Should we head outdoors?”
1. Choose the Yes, Yes story
2. Choose the Yes, No story
3. Choose the No, No story
4. Choose the No, Yes story
26. Name your file using the class protocol
Adventure(YourName)
27. The boy wonders what he
is going to do for the day.
You, as the player, decide
what the boy is going to do
The story ends.. or the
player goes back for
another ending!
1. Create story ending backdrop!
1. Choose the Yes, Yes story
2. Choose the Yes, No story
3. Choose the No, No story
4. Choose the No, Yes story
1. Create your sprites or get them
from our backpack materials!
2. Bring the the boy sprite into the
room and tell the player the rules
of the story
28. You, as the
player, decide
what the boy is
going to do
The story ends..
or
goes back for
another ending!
The boy wonders what he
is going to do for the day.
OK, let’s...
Complete the setup
for all of the stories!
1. Create your sprites or get them
from our backpack materials!
2. Bring the the boy sprite into the
room and tell the player the rules
of the story
29. Head over to Studio 8 and open the project called
“BackpackSpritesBackdrops”
https://scratch.mit.edu/studios/28848159/
30. We’re going to take ALL the sprites from this
project and add them to our backpack one by one!
31. First click on the stage..
...then head over to
the backdrops tab!
33. Now that we have backpacked
all the sprites and backdrops we
need, we can leave this project
and head back to the one that
we created earlier
Let’s start by adding the
backpacked sprites into our new
project
34. Here are all the sprites you should have in your new
project:
35. Now let’s go to the backdrops tab...
And add all the
backbacked backdrops
into our project
36. Here are all the backdrops you should
have in your new project:
NOTE: We’ll be using
“backdrop1” later so
we’ll drag it to the
bottom for now
CalmOcean
Bedroom1
KitchenCounter WavesRollingIn
Park
KitesInTheSun backdrop1
37. You, as the
player, decide
what the boy is
going to do
The story ends..
or
goes back for
another ending!
The boy wonders what he
is going to do for the day.
OK, let’s...
Complete the setup
for all of the stories!
1. Create your sprites or get them
from our backpack materials!
2. Bring the boy sprite into the
room and tell the player the
rules of the story
38. We have so many different sprites that come and go
throughout the program...
...which means we’ll be using the show
and hide block a lot!
39. Many of the sprites also have a lot of different costumes!
...which means we’ll be using the switch
costume to block a lot!
CookingArms
Standing KiteArms KiteArms1 KiteArms2 KiteArms3 KiteArms4 Shorts
40. When the program starts, we
want every sprite except the
boy to be hidden
We need the
when green flag
clicked block to
activate the
code!
But it won’t work on it’s own!
The hide block will
allow us to do this
NOTE
● Don’t forget to backpack the code
and add it to all the sprites
except for the boy sprite
41. When the program starts, we
want to the boy to be seen
The show block will
allow us to do this
We need the
when green flag
clicked block to
activate the
code!
But it won’t work on it’s own!
42. When the program
starts, we want
the boy to be in
standing in his
room
So, we’ll set the switch
costume block to
“Standing”...
...and go to the
backdrops tab...
43. ...where we will be using the first backdrop: Bedroom 1
These are all the backdrops we’ll be using throughout the program
CalmOcean
Bedroom1
Park KitchenCounter WavesRollingIn
KitesInTheSun backdrop1
44. Let’s go back to the code tab
*make sure you are in the
right workspace (bedroom1)!
45. Now we want to
have him in his
room when the
program starts
In the first step, we
made sure that the
boy can be seen in
the right costume
46. We can do this by using the switch backdrop to block
and activating it by using the when flag clicked block
47. The boy is going to be “walking” into the middle of his room so we want
him to the far left side of the screen.
● By adding the go to x/y
block, the boy will
always start at the left
side of the screen
● Notice how the
coordinate points
change when you move
your sprite to a
different location on
the stage
48. We want the boy to start at the
edge of the screen and “walk”
into the center
Test Your Code!
49. Now we’re going to have the boy start his conversation
about his weekend plans by using the say block:
(You can change up the sentences if you’d like)
Test Your Code!
50. Uh oh! The boy is talking way too fast!
Test Your Code!
Let’s change the
seconds so that the
user has more time to
read the words!
52. The boy wonders what he
is going to do for the day.
You, as the player, decide
what the boy is going to do
The story ends.. or the
player goes back for
another ending!
1. Create story ending backdrop!
1. Create your sprites or get them
from our backpack materials!
2. Bring the the boy sprite into the
room and tell the player the rules
of the story
We are going to save the
middle for last!
1. Choose the Yes, Yes story
2. Choose the Yes, No story
3. Choose the No, No story
4. Choose the No, Yes story
53. Complete the
backdrop that says
that the story is over!
(regardless of which story it is)
The story ends.. or the
player goes back for
another ending!
1. Create story ending backdrop!
54. Remember the backdrop that we said we would be using later? Well, it’s
time! We are going to use it to make the ending slide for all of the stories!
55. Let’s rename the backdrop to “TheEnd”
We want the player
to know that:
They are at the end
of the story AND
they need to click
on the green flag to
try a different story
We are going to
write this on two
separate lines
56. Let’s make the first line a little bigger
Feel free to change the font,
color, outline, or anything
else to personalize your text!
57. I changed the outline...
...and the color
And we’re done
with the ending!
58. The hide block will
allow us to do this
We need the when backdrop
switched switches to block to
activate the code!
But it won’t work on it’s own!
Now we want to make
sure that all the sprites
are hidden when the
end backdrop appears!
59. We want to make sure ALL the sprites are hidden
when the end backdrop appears
so we’re going to backpack the code... ...and add it to all the sprites
60. The boy wonders what he
is going to do for the day.
You, as the player, decide
what the boy is going to do
The story ends.. or the
player goes back for
another ending!
1. Create story ending backdrop!
Time to tackle the middle!
1. Create your sprites or get them
from our backpack materials!
2. Bring the the boy sprite into the
room and tell the player the rules
of the story
1. Choose the Yes, Yes story
2. Choose the Yes, No story
3. Choose the No, No story
4. Choose the No, Yes story
61. Let’s start completing
the story options the
player can give the
sprite!
You, as the player, decide
what the boy is going to do
1. Choose the Yes, Yes story
2. Choose the Yes, No story
3. Choose the No, No story
4. Choose the No, Yes story
62. Ok, how do we start coding this story! - these stories!
You and I make decisions every day.
● If it is raining outside...
○ We can decide to wear a raincoat - or -
○ Bring an umbrella - or -
○ Bring a raincoat and an umbrella….
● If we are leaving the house about what our considerations are in
reference to eating lunch...
○ What time are we going to come home? Are we even
going to eat lunch outside of our home?
○ Do we have enough money to eat out?
○ Do we have someone to eat lunch with? Is our lunch friend
going to be at school today?
○ Do we have time to pack a lunch?
In today’s class we are going to learn how to teach the computer to make
decisions, based on the choices typed in by the player, by using Boolean
expressions (true/false) inside of a conditional (if/else).
We want to make sure that player is in control of telling the story!
Flowchart
● Flowcharts help programmers plan their
programs, especially when they need to
code conditionals! It keeps things
organized.
The
diamond =
a decision
made by
the program
The
rectangle =
the action
Boolean
value:
True/False
63. ● Boolean values are ‘truth values’ that can only
have two possible outcomes –True or False.
So what is a Boolean value?
True False
Yes No
1 0
On Off
If, yes Else
● Since computers cannot understand words like
humans do, they store True values as ‘1’ and False
values as ‘0’. The language that computers
understand is called ‘Binary Code’. Like we are here
talking to you in English, Computers talk in Machine
language.
Hello
computer.
How are you
today?
https://www.rapidtables.com/convert/number/ascii-to-binary.html
I’m fine
thank
you.
64. In Scratch, Boolean blocks have a very special shape that
help you differentiate them from other blocks.
There are 3 kinds of Boolean blocks in Scratch:
1 2 3
65. 2
….and we are going to use all 3 types of Boolean values --
but our focus in this class is going to be on #2: Operations
Reviewed in class Reviewed in class
66. First let’s see the overall plan for our stories!
Should we
head
outdoors?
Indoor
Outside
This is a bit messy. Is there a better way to organize the information?
67. YES! Another way to look at the story is through the all
of the Boolean player response combinations:
YES
1
YES
1
Outside Indoor
Kites Beach
NO
0
YES
1
Outside Indoor
Cookies Samosa
YES
1
NO
0
Outside Indoor
Kites Beach
Outside
Outside Indoor
NO
0
NO
0
Outside Indoor
Cookies Samosa
Indoor
68. And yet another way
to look at the story is
by using a flowchart!
This page has a
pictorial flowchart and
a graphic flow chart.
They each tell the
entire storyline of 1
story - looking at both
the True and the False
options (boolean).
They both say the
same thing - use the
one you are
comfortable with!
Sprite speaking &
giving “how to
create story”
instructions
Should
we head
outdoors?
Yes or No?
Chart page 1 of 3
69. Flowchart:
Yes No
Yes No
Should we fly
a kite?
Ok, we can
stay indoors.
Let’s make
something to
eat. How
about
samosas?
Chart page 2 of 3
70. Yes
Should we fly
a kite?
End of story
Show
“End of
Story”
backdrop
Fly the
kite
Great! Let’s head out
and fly together!
Yes No
Flowchart:
Yes
Chart page 3 of 3
72. Now, let’s break that down starting with the question that starts off each story:
73. Now for the storyline starter question. The player must
choose an (boolean) answer - Yes (True) or No (False).
● Each response the player
types in has a coded
storyline associated with it.
● The response to this question
is Yes or No (boolean)
● In order to continue with the
program the computer needs
an acceptable response
74. Let’s check the status of our code….
Starts the program
Makes the boy show up on the first backdrop of the program
The “standing” costume is being used
The boy sprite starts in the corner of the backdrop. This is his starting position.
The boy sprite moves from the corner of the stage to the center of his room.
The boy sprite welcomes the player and shares rules.
same.
same.
Sprite asks the Question that starts every story.
Waits for player to respond - Yes (true) or No
(false) {boolean}
Test Your Code!
75. The storylines run on a conditional:
● If the play chooses yes, then….
● Another way to say that is: If the answer
is yes, then...
● If the player chooses no, else….
When there are no more choices for the player
to make the story ends and the computer runs
a final action
How does the storyline process work?
Sprite asks the Question that starts every story. Waits for player to
respond - Yes (true) or No (false) {boolean}
76. 1
● We did all of this coding as
we prepared the boy sprite for
his position on the screen.
● Here is an outline of the
meaning of each line.
● Now it is time to build the next
section of code: the
conditional boolean statement
78. 3 steps to building a boolean variable
1. Pull the control,
operator and
answer blocks
2. Because a boolean
response can only
be True or False
(see table) you need
to assign it a True
value because we
are working on a
Yes answer!
3. Combine the
operator and
sensing blocks and
place them in the
control block - done!
2
79. 0. staying inside
Now we need to determine what actually happens when
the player answers “yes.” The player has two options:
3
We can pose this question by asking
about one of the options: going outside
1. going outside OR
80. If the player types in YES as
their answer their reward is
another question!
And we handle
that question
the same way
we handled the
first question.
The process is
THE SAME!
81. Build a new (2nd) boolean variable
1. Pull the control,
operator and
answer blocks
2. Because a boolean
response can only
be True or False
(see table) you need
to assign it a True
value because we
are working on a
Yes answer!
3. Combine the
operator and
sensing blocks and
place them in the
control block - done!
2
82.
83. In this case, when
there is a YES we want
to have the boy
acknowledge that we
are flying a kite...
...and then proceed
with the action - Why?
Because flying the kite
is the end of this
storyline!
Now we need to determine what actually happens when
the player answers “yes” to the 2nd (boolean) question
84. If the player types in YES
as their answer their
reward is to fly a kite!
NOTE: We are
putting a
condition block
INSIDE another
conditional
block!
85. Now let’s make
the kite fly!
● The backdrop is going to
change twice
● The storyline is going to
end
86. When the player says YES to flying a kite we want to broadcast a message that
will allow the boy sprite to know when to go to the park and change his costume
in order to fly his kite!
Let’s make a new
message
And name it
“FlyKite”
87. We’re also going to track the choice of the player using
boolean variables!
Let’s make a new
message
And name it
“Kite or Beach”
88. We’ve already established
that 1=true and 0=false
So if the player chooses yes
(true), we want to set the
boolean variable to 1
And if the player chooses no
(false), we want to set the
boolean variable to 1
90. Now let’s focus on changing the
costumes!
The boy sprite has 14 different
costumes! 7 of them are for flying
the kite!
If we switch between these costumes,
it will look like the kite is flying!
See how the kite gets higher with
each sprite?
Test Your Code!
91. Your code should look
like this!
Nothing is happening! That’s because it is moving so fast that it
looks like there is no pause in between the costume changes!
We’ll need to add wait blocks in
between these lines of code!
1 second is a little too long for
costume changes, so we’ll do .25
seconds instead
Test Your Code!
92. Now we are going to switch the backdrop to give the feeling
that the kites flying high in the sky! So at the end of the
costume switches we are going to switch the backdrop!
Your code should
look like this!
93. When the backdrop
switches to
“KitesInTheSun, we
want:
1. The boy sprite to
disappear
2. The kite sprite to
appear
3. Have the kite look
like it’s flying”
94. When the backdrop
switches to
“KitesInTheSun, we
want:
1. The boy sprite to
disappear
2. The kite sprite to
appear
3. Have the kite look
like it’s flying”
Click on the kite sprite to go to the kite workspace
We can use the show block to make
the sprite appear
We can use the when backdrop switches to block to
activate the code
95. When the backdrop
switches to
“KitesInTheSun, we
want:
1. The boy sprite to
disappear
2. The kite sprite to
appear
3. Have the kite look
like it’s flying”
We want the kite to look like it continued where it left
off on the stage go we’re going to drag the sprite to the
bottom of the screen and start at that coordinate
96. When the backdrop
switches to
“KitesInTheSun, we
want:
1. The boy sprite to
disappear
2. The kite sprite to
appear
3. Have the kite look
like it’s flying”
Now we want to have the kite fly all over the screen. We
can use the glide to a random position block
I wanted my kite to glide slowly so I changed the block
to 5 seconds; you can change the the timing to your
preference
To make the kite glide more than once, I added a repeat
block and changed the number to 3
97. When the backdrop
switches to
“KitesInTheSun, we
want:
1. The boy sprite to
disappear
2. The kite sprite to
appear
3. Have the kite look
like it’s flying”
After 3 glides, we want the story to end. So we’ll hide
the sprite...
...and switch the
background to the end
98. This is what your code
should look like:
Test Your Code!
We can have the kite change costumes to make
the flying look more realistic!
We need to start with a different activator because we want both codes
running simultaneously
To make the costumes
keep changing
Always add a wait block when
switching between costumes so that
you can see the transition!
To switch costumes
100. Re-start story from
the beginning!
Sprite speaking &
giving “how to
create story”
instructions
Should
we head
outdoors?
Yes or No?
Chart page 1 of 3
101. Flowchart:
Yes No
Yes No
Should we fly
a kite?
Ok, we can
stay indoors.
Let’s make
something to
eat. How
about
samosas?
Chart page 2 of 3
102. Yes
Should we fly
a kite?
No
Show
“End of
Story”
backdrop
Go to the
Beach
Yes No
Flowchart:
Alright, let’s go to
the beach instead!
End of story
Go to the
beach.
*
Touch
the crab.
Chart page 3 of 3
103.
104. Let’s start by introducing the beach using a say block
Test Your Code!
Introduce:
● Ex: “Alright let’s go to
the beach instead”
*NOTE: In boolean logic
else = no = False = 0
105. Let’s start by introducing the beach using a say block
1
2
1. Broadcast a message to allow the sprite to know
when to switch backdrops and costumes
2. Since the boolean variable “Kite or Beach”
allows us to track the choice of the player, let’s
set it to 0
a. 0 - The player chose to go to the Beach
b. 1 - The player chose to fly the kite
106. 1. When the player says NO to flying a kite we want to broadcast a message that will
allow the boy sprite to know when to go to the Beach and change his costume
Let’s make a new
message
And name it
“Beach”
107. 2. We can also make sure to set the boolean variable we created to 0.
Kite or Beach
1 True, the player has
chosen to fly a kite
0 False, the player has
chosen to go to the
beach
Variable Key
108. Now we can decide what happens when the “Beach” message is
broadcasted
First, let’s switch to the beach
backdrop
We already have ALL the backdrops we need
● We can also show
the variable so the
player can also keep
track of their choices
We can show a variable on stage TWO ways..
1. The checkbox will show the variable the
ENTIRE time the project runs
2. The show variable block allows us to decide
exactly when the variable should show
Test Your Code!
109. Now we can decide what happens when the “Beach” message is
broadcasted
● Oh look, I remember
that we have a
shorts costume!
Since we’re at the beach,
we can have Avery wear
something appropriate
And introduce a crab!
We already have a crab sprite from the backpack, then
we can code it to switch the tide! It has two costumes
crab1-a crab1-b
Test Your Code!
110. In the crab workspace...
Let’s make sure it hides in
the beginning and then
appears when the backdrop
is on the beach
111. Avery introduced that when the crab is clicked, it can switch the tide
of the ocean….
But first, we can have the costumes switch
back and forth every time the sprite is
clicked
To switch the tide, we can create
a variable “Switch” to make sure
that the backdrop can change
112. Avery introduced that when the crab is clicked, it can switch the tide
of the ocean….
We can make sure that the backdrops
switches every time the sprite is clicked
by using an if-then block
Then if the switch variable from the
last time the program was run and
the player chose to go to the beach
was set to 0
● Then we can change the
variable to 1
If the variable was set to anything
else
● We can set the variable to 0
113. Avery introduced that when the crab is clicked, it can switch the tide
of the ocean….
Now let’s actually switch the backdrops
based on the value of the variable
Test Your
Code!
114. Let’s show the variable so the player can see the number switch
back and forth as they put together their different stories
● Find your code that shows the crab
when the backdrop switches to the
ocean and add the block to show the
variable
Test Your Code!
The “Switch” variable is on top
of the “Kite or Beach”
variable. Let’s fix this by
dragging the variable “Switch”
down on the stage
115. It works! We can now go back to Avery’s sprite and end the
story
Let’s give the player time to
watch the crab change the
tides then switch to the ending
backdrop
Test Your Code!
116. It works! Under the Avery’s workspace, let’s take care of what
needs to happen to clear the clutter on screen
● ‘Kite or Beach’ variable: hide
● ‘Switch’ variable: hide
● ‘Avery’ sprite: hide
● Crab sprite: hide
Test
Your
Code!
Let’s hide the two variables
and this sprite using the hide
variable block and the hide
look block
117. It works! We can now go back to the crab’s workspace and
hide the sprite
Test
Your
Code!
● BUT we can see the ‘Switch’
variable so let’s hide it in the
beginning of the story, after
hiding the ‘Kite or Beach’
variable
Test
Your
Code!
118. Let’s improve the storyline with some background music
Under Avery’s workspace, switch to
the sounds tab
We can delete these sounds because
we won’t be using them
Choose a sound you like..I
chose “Odesong”
119. Let’s improve the storyline with some background music
switch to the code tab
Test Your
Code!
● When the green flag is
clicked to start the story, we
want the music to play in the
background
○ This means we need a
FOREVER LOOP
121. You can go back and explore blocks to create the other two
storylines
TIP: Follow the same format as the
one we used in the “if-then” part of
the block
● Ask a question like “Would
you like cookies or samosas”
then create the story based
on the player’s response
123. Before we begin we need to know what Boolean is!
● At the heart of Boolean Logic is the idea that all values are either True (1) or False (0)
○ The number 0 is false. While we generally use the number 1 for True, any non-zero number = True
TRUE
Is it
raining?
Bring an
umbrella
START
124. The operator block
is a boolean block-
used to declare a
statement true or
false...
...and an answer block
is used to set the
statement equal to the
answer
We want the answer to
be set to “yes” so when
we combine the answer
and operator block, we
get:
Answer (outdoors) = Yes
126. Yes No
Yes No
Should we fly
a kite?
Ok, we can
stay indoors.
Let’s make
something to
eat. How
about
samosas?
Live drafts
127. Yes
Should we fly
a kite?
End of story
Yes
Show
“End of
Story”
backdrop
Fly the
kite
Great! Let’s head out
and fly together!
Yes No
UE
Live drafts
128. Yes
Should we fly
a kite?
No
Show
“End of
Story”
backdrop
Go to the
Beach
Alright, let’s go to
the beach instead!
End of story Go to the
beach.
*
Touch
the crab.
129. Live drafts
Yes No
Should we fly
a kite?
Ok, we can
stay indoors.
Let’s make
something to
eat. How
about
samosas?
130.
131. End of story
Show
“End of
Story”
backdrop
Alright,
let’s go to
the beach
instead!
Go to the
beach.
*
Touch
the crab.
No
132. And the last way to
look at the story is
by using a flowchart:
UE
Sprite speaking &
giving “how to
create story”
instructions
Should
we go
outdoors?
Yes or No?
134. Yes
Yes
Should we fly
a kite?
No No
Show
“End of
Story”
backdrop
Flowchart:
Alright
let’s go
to the
beach
instead!
Go to the
beach.
*
Touch
the crab.
End of story
135. Yes
Yes
Should we fly
a kite?
No No
Show
“End of
Story”
backdrop
Alright
let’s go
to the
beach
instead!
Go to the
beach.
*
Touch
the crab.
End of story