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!
https://online.coolest
projects.org/
19. But first...
Shoutout to Zoe from the Scratch Team!
The Hungry Hare
game is based off
of Zoe’s game!:
https://www.youtu
be.com/watch?v=1j
HvXakt1qw
29. Not here last week? No problem!
Here’s the link to the studio for today’s session:
Scratch Studio - India Scratch: Class #5-Scoring (mit.edu)
To Remix last week’s project go to Mera’s file in Class #5 Studio and
click to open...
37. But first, what is a Variable?
● Variables are data values (i.e. numbers, names) that can change when
the program is asked a question, for example, age/birthday, etc.
● A variable is a storage location paired with an associated symbolic
name (an identifier) which contains a value
● A variable is a storage location for data
38. But first, what is a Variable?
● Variables are data values (i.e. numbers, names) that can change when
the program is asked a question, for example, age/birthday, etc.
● A variable is a storage location paired with an associated symbolic
name (an identifier) which contains a value
● A variable is a storage location for data
What??
40. Variable Explained: Your Mission
Programmer
YOU!
● You want to invite your friends to your birthday party.
● You want each of your friends to feel special so you
want the invitations to have their names on it!
● You are inviting 10 friends but don’t want to write out
everybody name
○ ouch! Your hand would hurt!
○ the postal service is SO s-l-o-w
○ it’s COVID! You can’t just give it to them in
person!.......
41. Variable Explained: Your Mission
Programmer
YOU!
● You want to invite your friends to your birthday party.
● You want each of your friends to feel special so you
want the invitations to have their names on it!
● You are inviting 10 friends but don’t want to write out
everybody name
○ ouch! Your hand would hurt!
○ the postal service is SO s-l-o-w
○ it’s COVID! You can’t just give it to them in
person!.......
What should
you do??
42. Variable To the rescue!
That’s ok
programmer!
I can help
you!
I am a
coding
superhero!
43. Variable To the rescue!
Really?
How does
that work?
Let me tell
you a
story...
YOU!
45. What is my
value?
Who
Am I?
What data
am I
responsible
for storing?
Variable Explained
● I am a storage location that gets paired with an associated
symbolic name (an identifier) which contains a value
51. Variable Defined Here are the
names of
my friends
YOU!
Diya
Kevin
Navaneeth
Nikita
Usra
Aadil
Pratyush
Ayaann
S.K. Sowmya
Arnav
52. Variable Defined
Great!!
Name
● A variable is a storage
location paired with an
associated symbolic
name (an identifier)
which contains a value
storage
location
Name
symbolic name
(an identifier)
53. So the way you turn
on my superpowers
is as follows:
Name
Step # 1:
Go to the variable menu...
And click on Make a Variable
54. So the way you turn
on my superpowers
is as follows:
Name
Step # 2:
1. Give me my “symbolic name”
2. Leave the variable marked
“For all sprites”
3. Click on “OK”
1
2 3
1.
2.
3.
Name
55. Name
Step # 3:
● you can see my “symbolic
name” on the taskbar
Variables
I can use my
superpowers for
you when…...
58. So the way you turn
on my superpowers
is as follows:
Name
Go to the variable toolbar and get
the “set my variable to () block
Then make the “0” = the name of
your friend!
59. Variable Defined Let’s make
one for Diya
first!
YOU!
Diya
Kevin
Navaneeth
Nikita
Usra
Aadil
Pratyush
Ayaann
S.K. Sowmya
Arnav
60. OK! Let make a
birthday card for
Diya! First...
Name
Then make the “0” = Diya!
(because we want her to be
displayed on the birthday card)
Step # 1:
64. Name
1. Diya’s name shows up in both places
2. ...at the same time
3. ...and you didn’t write anything by hand!!!!
WOW!
YOU!
65. HOW?
YOU!
Show & Tell: Birthday Card Sprite
No code required! It just site in the
background looking great!
66. HOW?
YOU!
Show & Tell: Balloon Sprite
Code translation: The “Name” variable, set to
“Diya” is going to show for “7” seconds
67. HOW?
YOU!
Show & Tell: Party Hat Sprite
Code translation: The “Name” variable, set to
“Diya” is going to show for “7” seconds
68. Wait! You are using
the same code for
the balloon AND
the party hat?
YOU!
Show & Tell: Tale of 2 Sprites
Code translation: The “Name” variable, set to
“Diya” is going to show for “7” seconds
69. Show & Tell: Tale of 2 Sprites
Code translation: The “Name” variable, set to
“Diya” is going to show for “7” seconds
YES! That
is the
superpower
of a variable!
Name
70. End of the Story!
Now I know how to
make a birthday
card for each one of
my friends!
YOU!
Excellent! Glad I could
help! Call on me anytime!
My superpowers are
always available!
Name
71. Now let’s go
back and apply
our knowledge
about variables
to adding a
score to the
HareGame!
My superpowers
are always
available!
Name
72. Let’s review: There were 4 steps to making this game...
1 2
3 4
Make the
hare jump
Make the
game
obstacle
Make the
strawberry
for the
hare to eat!
Make the
hare move
STEP 1
STEP 3
STEP 2
STEP 4
73. Let’s review: Step #1 & #2 are not related to scoring;
they deal with costume details.
On the other hand, the ball and strawberry cause things
happen to in the game. Let’s look closer…..
3 4
Make the
game
obstacle
Make the
strawberry
for the
hare to eat!
STEP 3 STEP 4
74. Objective of Strawberry
How is the strawberry an
advantage in the game?
If the hare touches the
strawberry the game
continues.
The strawberry = ONE
point.
Objective of Ball
How is the ball a
challenge in the game?
If the hare touches
the ball the game will
stop.
The ball = ZERO
points.
Objective of The Hare
The hare is the
trigger
(conditional) for
when the score
increases or
stops the game.
What is the hare’s
role in the game?
76. Objective of Strawberry
How is the strawberry an
advantage in the game?
If the hare touches the
strawberry the game
continues.
The strawberry = ONE
point.
Objective of Ball
How is the ball a
challenge in the game?
If the hare touches
the ball the game will
stop.
The ball = ZERO
points.
Objective of The Hare
The hare is the
trigger
(conditional) for
when the score
increases or
stops the game.
What is the hare’s
role in the game?
● Now that we have reviewed the details
of the game let’s get ready to start
coding our score!
● Does the hare Sprite need a coding
variable?
○ NO! Because it is the trigger
(conditional) of the action
○ We need to code the score where
counting happens!
■ Ball = 0, stops game
■ Strawberry = +1 to score
77. Objective of Strawberry
How is the strawberry an
advantage in the game?
If the hare touches the
strawberry the game
continues.
The strawberry = ONE
point.
Objective of Ball
How is the ball a
challenge in the game?
If the hare touches
the ball the game will
stop.
The ball = ZERO
points.
Objective of The Hare
The hare is the
trigger
(conditional) for
when the score
increases or
stops the game.
What is the hare’s
role in the game?
● Let’s make the
game better by
telling the player
what is going on
when the hare
touches the ball.
● Solution: make a
“GAME OVER”
backdrop if/when
the hare touches
the ball
● When you play
the game it stops
if/when the hare
touches the ball
● No additional
coding required
to “not” add
points to the
game
Review Code
78. Let’s make the game more “user-friendly” and let
players know when the game is over!
To do that we’re going to create a “GameOver” backdrop
Click on the Stage and then Backdrops
1
2
1 2
79. Next we can make a copy of the “BlueSky” backdrop and
use it, with modifications, for our “GameOver” backdrop
To do this, we
1. right-click on the
backdrop and
2. click on the
“duplicate” button
80. Now, let’s rename the file to “GameOver,” so we
know which backdrop it is when we code.
TIP:
● Always name coding
elements based on what
makes them unique!
● This habit allows you to
remember what the
element looks like when
you choose them name
on a coding menu!
81. With our backdrop costume named we can begin to
modify the backdrop to “talk” to the player of the game.
● Clicking the “T”
(for Text) on the
tools menu
● Type “Game Over!”
83. We can change the text font type and/or the
size of the font! So many options!
84. Let’s write a second line of text telling the
player how to reset the game!
Challenge!
Choose a different
font for the second
text
85. Hummm...where should we code the “GameOver”
backdrop? The hare, the ball, or the strawberry?
The ball! Why?
The Ball Sprite
has the code
that causes the
game to STOP!
86. When do we want our “GameOver” backdrop to show?
● Before the game stops!
● So we’ll need to place the
“switch backdrop to()” block
+ “GameOver backdrop in the
code before everything stops
( )
87.
88. Oh No! The game is still running while the
“GameOver” backdrop is up!
Correct Incorrect
beginning backdrop beginning backdrop
89. How do we fix that? We need the game to start on
the BlueSky backdrop - so let’s code that in!
*NOTE: Place the
backdrop just after the
“when green flag clicked”
block so the backdrop
always appears in the start
of the game
90.
91. Great problem solving! The appropriate backdrops
are displayed at the correct time - the code works!
Start of the
game backdrop
Correct
End of the game
backdrop
Correct
92. Objective of Strawberry
How is the strawberry an
advantage in the game?
If the hare touches the
strawberry the game
continues.
The strawberry = ONE
point.
Objective of Ball
How is the ball a
challenge in the game?
If the hare touches
the ball the game will
stop.
The ball = ZERO
points.
Objective of The Hare
The hare is the
trigger
(conditional) for
when the score
increases or
stops the game.
What is the hare’s
role in the game?
● When the hare touches (eats) the
strawberry it earns a point!
● We need create code that adds
points to the score (+1) when the
hare touches the strawberry
Score: 0 Score: +1
93. Let’s use the 3-step process we just learned create the variable that
will allow the strawberry to add 1 point when touched by the hare.
Make sure you are on the strawberry’s workspace!
94. How to make a
variable….
Step # 1:
Go to the variable menu...
And click on Make a Variable
95. Step # 1:
1) Go to variable menu
2) Click on “Make a Variable
96. So the way you turn
on my superpowers
is as follows:
Score
Step # 2:
1. Choose a “symbolic name”
2. Leave the variable marked
“For all sprites”
3. Click on “OK”
1
2 3
1.
2.
3.
Score
97. Step # 2:
1) Choose a “symbolic name”
2) Leave the variable marked “For all Sprites”
3) Click on “OK”
“For all sprites:” This is the
default choice. All Sprites can
see and use this variable.
“For this sprite only:” Variable can
only be used by 1 sprite. The
restriction is labeled.
98. TIP! *Make a mistake with a variable?
*Want to rename of delete?????
Right click on the variable itself
When you are selecting a variable
99. Score
Step # 3:
● you can see my “symbolic
name” on the taskbar
I can use my
superpowers for
you when…...
Variables
102. The hare earns a
point every time it
touches (eats) a
strawberry!
Score
The game is set to start at zero.
Once the hare touches a
strawberry we need to increase
our variable “score” by 1
Step # 1:
Go to the variable toolbar
and get the
“change my variable by () block
103. second... choose
the symbolic name
for the variable!
Name
Change the symbolic name of the
variable to “score”
Step # 2:
104.
105. Now you should see your score add by 1!
The game is complete!? YES!!!!!!
119. Video sensing definition
● Video sensing is computer software
that tracks motion (and sometimes
color) through video
○ The computer looks at the images in a video frame
by frame!
● Allows the computer to perform
actions on virtual objects based on
YOUR movement!
○ Just like the filters that move on apps like
Snapchat, Instagram and more
120. Hmmm...I wonder if there’s a way to play
with video sensing in Scratch?
121. There’s a way to do it! Scratch has many
extensions that allow you to expand your skills
126. OH NO! Nothing happens and we still
don’t see our video
127. In order to use your camera, Scratch needs
permission to access it.
1. Click on the camera icon with an on
the website URL tab
2. The tells us that camera is blocked
3. This icon allows you to grant the website
permission to use your video
128. Select the “always allow” option and click done
Scratch CAN’T access camera Scratch CAN access camera
https://support.microsoft.com/en-us/windows/turn-on-app-permissions-for-your-camera-in-windows-10-87ebc757-1f87-7bbf-84b5-0686afb6ca6b
Permission to use camera-Microsoft
129. WAIT!! Notice this message
● The camera might not
immediately work
● To fix this, reload the
page
“This page may need to be reloaded
before the new settings take effect.”
130. Hmmm..we still can’t see the camera, let’s play with the
video sensing blocks one by one and see what happens...
131.
132. Grr...We still don’t see anything!!!! I wonder if
something will happen when I move around...
134. ● When the amount of movement a person makes
is greater than the selected number….
○ The code that follows will run
● Goes from 0 to 100
○ 0: Don’t need much movement
○ 100: Needs a lot of movement
135. Let’s look at what else we can do with the video.
The drop down menu shows us options, I’m going to
try selecting “off”
136.
137. ● We use the green flag because we’ve
always started our code with before
● The green flag “activates” or runs our code
● But our code for this activity does not have
this block… So How do we test our code?
In the past we have been testing
code using the green flag...
138. ● Our code starts with the dd
block
● So now our code is activated and runs
when the computer detects our
movements!
Tip: test your code by moving around!
160. I like the way it was before so I’m going to keep the
transparency at 50. You can do whatever you like! This is
something to personalize to your tastes and the
capabilities of your computer!
161. WOOHOO, that was FUN!! Now you know
how video sensing works in Scratch!
162. Objective of the Balloon Popping Game
1. The game is to
touch the
moving balloon.
2. Each balloon =
ONE point (+1)
is added to the
score.
163. 1. The game is to touch the moving balloon.
● The balloon isn’t moving yet
● How can we move the ballon?
○ What if we have it go to random places on stage
164. How can we move the ballon?
We can use this
block!
● Moves our sprite to
random places on the
stage
● You (as the
programmer) can’t
predict where the
sprite will be next
165. Under the “motions” tab, drag the “go to random
position” block to your code
168. Objective of the Balloon Popping Game
1. The game is to
touch the
moving balloon.
2. Each balloon =
ONE point (+1)
is added to the
score.
169. 2. Each balloon = ONE point (+1) is added to the score
● We need to keep track of points
● How can we store and keep track of values?
1
1 1
1
1
1
1
1
1
170. To do this, we need to create a variable!
● Purpose: store the
value of how many
points the player
scores
● Identifier: “score”
score
How can I use my
superpowers for
you?
171. Step # 1:
1) Go to variable menu
2) Click on “Make a Variable
172. Step # 2:
Score
1. Choose a “symbolic
name”
2. Leave the variable
marked “For all
sprites”
3. Click on “OK”
1.
2.
3.
2
3
173. Now the variable shows up! Make sure the blue
check next to the score variable is clicked
174. Objective of the balloon
When we “pop” the balloon, we get one point!!!
What is the balloon’s role in the game?
181. Hmm… wouldn’t it be nice to have popping
sounds to the balloon… Let’s add sound
This block will play the pop
sound
*Everytime motion is detected on the
balloon, it will make a “Pop” sound like
bubblegum!
182. Now we can hear the balloon pop
before it gets to new location on the
stage!!
Add the “play sound until done” block and move around to see
if it works...
183. WAIT!!!
● The scores keeps going up and up!
● What if I wanted to play with my
friend?
○ Hmm..I don’t want my friend to
continue using my own score
○ At what point will can the
player restart the score from 0
Change “my variable” to “score”
184.
185. OH NO! Now the score is always 0!
Let’s try setting the score to 0 when the green flag is clicked
186.
187. YEAH! It works now, but it’s a
little fast and I wonder if the
game can run smoother...
I remember seeing Ms.D’s code and I
liked that her score went increased
slower. Let’s try what she did
188. Even though we are not remixing the project, we
are ethical coders so we have to give Ms.D credit!
Thanks to Ms.D for her help!
189. It is like the If statement is the cause, the then statement is the effect
If: It was raining Then: I used an umbrella
● “If - then” bocks tell the computer to perform
an action when a condition is true
● The score goes up only when the computer detects
movement greater than 5 on the sprite (condition)
191. To add the > sign, let’s go under “operators” and drag the block with the
pointy edges that will fit in the condition of the “if-then” block
192. Now we can add the video sensing block we need to the condition
193.
194. The game works much better!
Let’s change it up and have the
balloon change colors
195. ● I want to dance and play
with music!
● Let’s add some background
music by going to the
“sounds” tab
FUN!!! The color changes and I have a brilliant idea...
198. I’m going to try out the sounds under “loops”
I like “Dance Sitar”, you can pick whichever one you like
199. Play the sound and test the game
● I think the music is too loud so I want it to be a little quieter
○ Use the “softer” button to do this
200. Under the code tab, add “another green flag
clicked” block the “play sound until done” block
201. OH NO! I want to keep playing but the music
stopped
● We want the music to
keep playing until we
leave the game
● Let’s use a forever
block which will repeat
the action again and
again and again!