0% found this document useful (0 votes)
319 views

Scratch FYK3

This document discusses using the Fun Palettes in Scratch to create interactive games and animations involving sprite interaction. It provides an example game where a cat sprite's distance to a mouse sprite triggers it to move, and the mouse touching a muffin sprite increases the score. The Fun Palettes allow sprites to sense each other's attributes, locations, and distances, enabling the creation of games involving collision detection and interactive behavior.

Uploaded by

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

Scratch FYK3

This document discusses using the Fun Palettes in Scratch to create interactive games and animations involving sprite interaction. It provides an example game where a cat sprite's distance to a mouse sprite triggers it to move, and the mouse touching a muffin sprite increases the score. The Fun Palettes allow sprites to sense each other's attributes, locations, and distances, enabling the creation of games involving collision detection and interactive behavior.

Uploaded by

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

interaction

SCORE 9 part script

part script forever


Cat
Muffin
forever point towards Little Mouse
SCRATCH for Your Kids © Seamus O’Neill 2021

if touching Little Mouse then if distance to Little Mouse 70 then

change SCORE by 1
move 2 steps

go to random position

wait 0.2 seconds

The Sensing, Operators, Variables and the Pen extension


(next chapter) are the interactive tools that make the fun
and enjoyment of SCRATCH complete. In all, we have nine
Little Mouse palettes and all the blocks we need to excite and inspire
creative coding. With the Fun Palettes we can count sprite
collisions and interaction. We can code one sprite to
sense another sprite’s location, direction, costumes, size
and colour, as well as the distance between them. In the
Mouse, Muffin and Cat Game, the Cat’s distance to the
Mouse is its cue to move. Mouse touching Muffin counts
Left right Arrow right as a score. Muffin reports the score and calls time on the
game. The Fun Palettes are the key to creating amazing
games, animations, puzzles, quizzes and interactive
learning excitement for children of all ages.

See the Mouse, Muffin and Cat Game on pages 48-49


37
Key learning points in Part 3: Sprite Interaction using the Fun Palettes
● Introduce four of the remaining SCRATCH Palettes (the 4 Fun Palettes):
Sensing, Operators, Variables (and Lists), including the Text-to-Speech Extension. Also . . .

● 1. Saving your work:


- including Drag-Copying code from one sprite to another
SCRATCH for Your Kids © Seamus O’Neill 2021

● 2. Cloning a Sprite: as an inactive copy, as an active copy

● 3. Sprite Sensing: the 3 Amazing Sensing Blocks (for touching, distance, attributes)
- including Colour Sensing, the User Input box and the Answer variable, Sprites in Draggable Mode

● 4. Operators: Numeric and String Data types


- Operator types: True or False, Logic operators, Text handling operators
- Combining Data types, String and Numeric data handling with the join operator
- linking a Mathemagic written assignment with Code

● 5. Variables & Lists: Counting, Multiples, Keeping a Game Score, using a Timer, a Variable with a List
- variable Readouts in Normal, Large and Slider Mode
- variables in Nested loops to create Rows (Across and Down)
- filling a List; by Direct input, by using the input block, by Answering Questions for input
- More Sprite uses: Animal pictures as costumes, Create a New Sprite, Use an invisible Sprite

● Target: Make a Game for Younger Children

● Advance your skills with the shared online projects

38
Fun With Easy Revision
Saving Your Projects Drag to Copy a Sprite’s Code
File Edit Tutorials Cat on its 1 Log in and start a new project. Save it as the Join Scratch Sign in

New
Bat and Bear. If you are offline on the Scratch
Desktop, save to your destination folder.
Save now
2 Get the Mountain backdrop from the library. 5
Save as a copy
3 Delete the cat and get the Bat from the Animals
Load from your computer
category in the Sprite library. 2
Save to your computer
4 Code the Bat as follows.
Scratch gives you the option to work online or The Bat Should Fly Left to Right.
offline. If you intend to work online and you when clicked the Bat
Press and Drag
would like to save your projects, it is is the
SCRATCH for Your Kids © Seamus O’Neill 2021

6 current
recommended that you set up a Scratch ID. If you Bat sprite
want to enjoy Scratch on an iPad, you must be
online. You can download the Scratch Desktop if 5
you would like to use Scratch 3 offline on a
18
desktop and laptop. With the Scratch Desktop Drag - Copy the Bat’s Code to the Bear
you don’t need a Scratch ID. However, if you Bear-walking
5 Get the Bear Walking sprite from the library.
want to share an offline project and show it to
6 Press and Drag the Bat’s code from the top onto
your friends, you will need a Scratch ID. Bear walking
the Bears’s thumbnail. When the tip of the
Scratch Desktop mouse-pointer is over the centre of the Bear’s
the wobble
File Edit Tutorials Cat Exer the code from the Bat
thumbnail DO NOT RELEASE it until the Bear’s
copies to the Bear thumbnail wobbles. When you see the wobble
New
release your hold. The script will copy to the
Load from your computer 50 x 10 = 500 steps Bear. If necessary drag the code again until it
Save to your computer copies. Select the Bear’s thumbnail and you will
8 see that it has a copy of the Bat’s code.
Log in and code this Sample project of 6 blocks:
Here is the script: (1) when the cat is clicked (2) Make the Bear 7 Set the Bear at the bottom of the stage at y: -150.
repeat 200 (3) rotation style all around (4) move Walk from Run the code and you should see the Bat and
20 steps (5) turn 10° (6) bounce on the edge. If Right to Left Bear both move from left to right.
exact, the cat will finish on its head at x;-16, y:-9 The Bat began on the left at : -250. Remove the minus to set the Bear’s starting
facing -90°. Save the Project, as Cat on its Head. location on the right at x: 250, y:-150. You must make the same change in x:
inside the repeat (4) loop. The Bat began with point in direction (90). Make
Off line: You need a destination folder on your the Bear point in direction (-90). Run the code and Save to update your work.
computer where you can save your Scratch
projects. Give the destination folder a name, e.g. Understand the Bat’s code: The Bat flits from the left (at x: -250) to the right side of the stage (at x: 250)
my Scratch projects. Complete the Cat on his by 50 loops of 10 steps. This is highlighted by the dashed line in the inside loop. It then returns to the
Head project in the Scratch Desktop. Go to File left and crosses to the right again, doing this a total of 4 times. As long as the total inside the dashed
> Save to your computer and save Cat on his Head lines is between 480 and 500 you can change the figures. The Bear should be slower than the bat. Try this
to the folder my Scratch projects. Check online. on the Bear : Change repeat (50) by (10) steps to repeat 120 by (4) steps. Make the Bat cross 8 times.

Check the facts of Cat on its Head at the Bat and the Bear is shared at https://scratch.mit.edu/projects/422673755
https://scratch.mit.edu/projects/444500420 Take it to the next level?
39
See the code inside the Bear Story at https://scratch.mit.edu/projects/378930326
Fun Palettes: Sprite Sensing
Sensing Palette and Blocks Colour Picking
Code Costumes Sounds The Cat and the Ball Bursting Balloons
Sensing
12 of 18 blocks
Motion
touching mouse-pointer ?

Looks
touching color ?

color is touching ?
Sound
distance to mouse-pointer Backdrop: Blue Sky
SCRATCH for Your Kids © Seamus O’Neill 2021

Backdrop: Beach Rio


Events ask What's your name? and wait
The ball is tossed by the wind. The cat is having Describe what happens and why it happens,
fun. All is well until they touch! Get the two when the balloon touches the green hedge.
answer Examples next page sprites and the backdrop from the libraries.
Control Script on
Code the sprites with one script on each. the Balloon
key space pressed ? when clicked
Script on the
Sensing mouse down ? Beachball forever Balloon 20
when clicked
19
Beachball glide 1 secs to random position
mouse x forever
Operators

mouse y random position


glide 0.5 secs to random position if touching color ? then

Variables the color picker


set drag mode to draggable wait 0.5 seconds The cat is interacting with change y by 200
the ball in two ways.
(1) pointing towards the ball next costume
backdrop # of Stage (2) reacting to being
My Blocks
touched by the ball
set ghost effect to 0
About the Sensing Palette when clicked Script on the cat
wait 0.25 seconds
Sensing blocks can sense events such as a mouse go to x: 0 y: -100
click, or one sprite touching another, or touching clear graphic effects
a colour, or if a key is pressed. Many Sensing forever Cat 2
blocks are Boolean shaped reporters that fit into
conditional blocks. The stack Sensing block ask () point towards Beachball Click the block. Click the color
picker and bring the picker to
and wait collects user input and stores it in the
if touching Beachball ? then the stage and click again.
answer reporter. The set draggable mode can be
The Cat and Ball is shared at
used to reposition a sprite in full screen mode. The
say Ouch! for 2 seconds https://scratch.mit.edu/projects/430521553
round attribute reporter* is probably the most
amazing and most useful of all Sensing blocks. Bursting Balloons is shared at
https://scratch.mit.edu/projects/430559964

40 Descriptive names of all Sensing blocks: touching () ; touching (color) ; colour () touching (color) ; distance to () ; ask () ; (answer) ; <key () pressed> ;
<mouse down?> ; (mouse x) ; (mouse y) ; () of () This is the attribute reporter whose two lists change depending on which sprite is selected;
set drag mode ; (loudness) ; (timer) ; reset timer ; (current year) ; (days since 2000) ; (username) ;
Fun Palettes: Data Types in Scratch Ask and wait for Input
Operators Palette and Blocks
Code Costumes Sounds Just Click an Operator
What is 3 quarters of 20?
You can click on any operator
Operators: all 18 blocks to get a hint box that tells you
say What is 3 quarters of 20?
Motion The four Maths operators ( +, –, x, ÷ ) its value and what a sprite
report the result of the operation on the would report in a say () block (plain text) string data
two numbers in the input windows. Try speech balloon.
Looks 3 quarters of 20 is 15
typing a letter in a Maths operator.

The pick random operator reports 7 2 sprite to sprite


Sound
a random number between the 14 string data numeric data
SCRATCH for Your Kids © Seamus O’Neill 2021

pick random 1 to 10
minimum and maximum of the two
Events values. The defaults are 1 and 10. say join 3 quarters of 20 is 20 4 3
2+2 4
50
this is a solution ALGORITHM
greater than, less than and equal to false
Control 50 compare two values and report true or
false. They are called relational operators. 2 2 4
Code, then click the duck.
50

Sensing true when this sprite clicked


21 duck
and
and, or, not are 3 logic operators which
are used to combine two or more Can you figure out why and wait
ask What is 3 quarters of 20?
or relational operators to produce a single c is true but b is false?
Operators
true/false result. Using these blocks if answer 20 4 3 then
not allow you to further refine your Numeric and
comparison of values. String Data say Correct. Well done!

join apple banana join () () links two values together and Scratch regards b as if it was else
reports the result. two letters with a plus sign
between them. It regards say Wrong answer. Click me and try again.
letter 1 of apple
The words ‘apple’ and ‘banana’ are holding text. only 4 = 4 or c as a an
length of apple
The blocks are useful for text handling. E.g. See operation or calculation What is 3 quarters of 20?
Length of a Name p. 43 and Spell a Word p. 47 which equals 4. The coder uses the
apple contains a ? division and multiplication operators to
About the Operators Palette construct the correct solution algorithm. The
There are no stack blocks Operators. All are rounded or angled (Boolean) coder has to know the Maths in order to code
mod reporters. Scratch uses Operators to code Numeric or String data. ‘Numeric’ the algorithm correctly. Scratch checks the answer
from the user against its own built in calculator. An
data refers to numbers operating ( +, – x or ÷) on each other. ‘String’ data incorrect answer brings the user back to the start.
round refers to plain text (letters or numbers). For students of mathematics, it is
useful to know that the drop list in the abs of () block has fourteen Maths Input the answer and click to confirm.
abs of functions such as square root, sin, cos, tan, log, etc.
15
Solution Algorithm is shared at https://scratch.mit.edu/projects/430591659
Descriptive names of all Operators: addition reporter ; subtraction reporter ; multiplication reporter ; division reporter ; pick random ; greater than ;
greater than ; less than ; equal to ; <> and <> ; <> or <>; not <> ; join reporter ; letter () of () ; length of () ; < () contains ()> ; () mod () ; round () ; abs of () ;
41
Fun Palettes: Mathemagic
Code the Solution Algorithm More Solution Algorithms
22
What number is
6 more than 38 ? The ask () and wait block makes the sprite when clicked
ask a question in a speech balloon, and What is 2 thirds
of 18 ?
give the user an input box to type the answer.
answer The light blue answer reporter stores whatever say Click me for a question.
the user types in the box, (right or wrong).

Duck
type your answer here when this sprite clicked “ 10 ”
Code the Duck with the two scripts.
If the question is ‘What is the capital of France? Scratch does not ask What is 2 thirds of 18 ? and wait Change the question if you like.
have the answer but the coder can give Scratch the answer. If the
SCRATCH for Your Kids © Seamus O’Neill 2021

user types the answer as Paris (but the coder gave Scratch the if answer 18 3 2 then
answer as Athens), then Scratch accepts Athens as correct and Paris
as incorrect! Maths in Scratch doesn’t work like that. The coder Why does the code need
say Correct.
codes the solution algorithm not the answer. Scratch has its own two Maths Operators to code
the correct solution algorithm
built in calculator. If the solution algorithm is stop this script to answer this question? 23
correct, Scratch will have the correct answer.
when clicked else “9”
Code the Cat with the two scripts.
say Click me for a question. say Wrong answer. Click me and try again. for 2 seconds

Cat
say What is 2 thirds of 18 ?
when this sprite clicked

ask What number is 6 more than 38 ? and wait Code each animal sprite with two similar scripts to the duck.
Deduce the solution algorithm from the speech balloons.
Did the coder
if answer 38 6 then code the correct
solution algorithm? What number is What number is
5 less than 52? double 18?
say Correct. The coder has to know
the Maths in order to code
stop this script the solution algorithm.

else
What number is 3 more
What number is
say Wrong answer. Click me and try again! for 2 seconds than a quarter of 20?
half of 30?

say What number is 6 more than 38 ?

42 Cat with Bowtie is at https://scratch.mit.edu/projects/472548877 Asking is shared at https://scratch.mit.edu/projects/431823614


Fun Palettes: More Mathemagic
2-step Sums Complete the Sums as a Written Assignment
This is an interactive resource that checks the outcomes of the written
(28 + 35) - 17 (31 + 27) - 19
A headset is
assignment. Sum number 1 is coded with two scripts as you can see.
recommend. Code sums 2, 3 and 4 in the same way. Input each answer to check it.
The speak

28 31
code is not
(27 + 33) - 26 (34 + 29) - 36 absolutely
necessary.

1 35 2 27
24
17 19
SCRATCH for Your Kids © Seamus O’Neill 2021

script
1 when clicked 1 of 2

Giga 1 set size to 60 %


27 34
when this sprite clicked
say (28 + 35) - 17
3 33 4 29
26 36
ask (28 + 35) - 17 ? and wait script 2 of 2

if answer 28 35 17 then

The above two-step sums are difficult for children too young to code. Those
say join answer is CORRECT
working with younger children might create a resource with easier sums but
with the same code structure. Use it to support homework and Maths lessons.
speak join answer is CORRECT

Examples of easier one-step solution algorithms:


stop this script

else
1 answer 9 18 2 answer 13 7
say Click me and try again

speak Click me and try again

3 answer 15 11 4 answer 24 8

say (28 + 35) - 17 ?

2-Step Sums is shared at https://scratch.mit.edu/projects/290080916 43


Fun Palettes: Count with a Variable
Variables and Text to Speech Count Down Variable
Code Costumes Sounds Daffy Duck! Can you count?
Of course I can. I’ll when clicked 25
Variables count to 10. Listen.
Code the Duck
Motion with this script. set Countdown to 10
Make a Variable
when clicked
New Variable say Countdown
Looks
Count set Count to 0
New variable name: Countdown
speak
tick to show / hide
repeat 10
Sound Count
set Count to 0 repeat until Countdown 0
change Count by 1
SCRATCH for Your Kids © Seamus O’Neill 2021

For all sprites For this sprite only

Events Cancel OK say Count “1”


change Count by 1 change Countdown by -1

Readout Monitors speak Count


wait 0.5 seconds
Control show variable Count
On the stage, you see Variable Readouts.
They monitor the value of the variable. Countdown
say
hide variable Count If you want to change the readout mode,
Sensing double-click the monitor window .
Normal Large speak Countdown
Count 9 Slider Mode Slider Mode can be between
Count 9 a minimum and maximum.
Operators
9
See example next page.

You are given a starter variable with the name, You must set the value to (0) before the say We have lift off

Variables
my variable, which you can use, rename or loop and change the value by (1) inside it.
delete. Code the Duck with a new variable The order of the blocks inside the loop, speak We have lift off
‘Count’. Counting is changing a number. because the duck should say “one” to start.
My Blocks
Text to The Variables Palette
Speech
A variable is a value that changes or varies. Start
with the set (variable) to () and in each iteration
Text to
Speech of a loop use change (variable) by a specified
amount. Scratch keeps a record of the changing
Text to Speech value in its memory. Tick the box beside the
Make your projects talk
variable reporter to see a readout mode.
A headset is
speak hello recommend. The Text to Speech Extension
Text to Speech allows synthesised speech in a We have lift off.
set voice to alto
Choose
Extensions
alto or tenor. project. It works well when the speak () block
is used after the unlimited seconds say () block.
set language to English

44 Lift Off is shared at https://scratch.mit.edu/projects/429595606


Count in any Multiple Length of a Name
Multiple 8
Slider Readout Code the
Duck to
normal readout
Create 2 large readout
Count in any when clicked 27
variables Multiple
slider from 2 to 12
Count and ask How many letters in my name? and wait
Multiple change slider range
Hedgehog
if answer length of hedgehog then
Bring up the Change slider range
context menu
Minimum value say join join Correct. There are answer letters in my name. for 3 seconds
Set Multiple
to Slider 2
SCRATCH for Your Kids © Seamus O’Neill 2021

Readout,
ranging Maximum value
from 2 to 12
12
How many letters in my name?
Cancel OK
8
I’ll count in any
when clicked
Multiple to 12.
26 Correct. There are 8
letters in my name.

Choose a number by slider then click me

A headset is
when this sprite clicked recommend. Code me with the same
question as the hedgehog.

6, 12, 18, 24 …
30, 36, 42, 48 …
Zebra

60
How many letters in my name?

…66, 72 8

Hedgehog’s Name Trick at https://scratch.mit.edu/projects/430759491

Count in Multiples at https://scratch.mit.edu/projects/437767789 45


Fun Palettes: Cloning a Sprite
Rows of Oranges More About Cloning in Scratch?
28 Make Scratch create as many as 10 x 10 rows Each clone has the same costumes, sounds, scripts, and
of oranges from just one orange. Use the variables as the original sprite but it acts like it is
Click me. original orange to Clone all the other oranges. independent e.g. From one original snowflake sprite,
What is a Clone? A Clone is a working copy of a you could code a snowfall. Similarly you could clone
sprite. Cloning is a feature of Scratch, that allows bubbles from a fish, bees swarming from a beehive, a
a sprite to create a working copy of itself while flock of birds in the sky etc. Snowfall
the project is running. In Rows of Oranges
cloning just makes a copy of the original orange.
29
Code Wanda
Across 10 Down 8 Script 1 of 2
SCRATCH for Your Kids © Seamus O’Neill 2021

Wanda
Get the 30 px grid, by name Xy-grid-30px. You
need two variables Across and Down in slider
Script 2 of 2
mode. With the limitations in mind, set the slider
draw a SNOWFLAKE
range to min of 2 to max of 10. The size of the - a small white dot
orange at 80% is about the size of a grid square. about 4 x 4 canvas
squares in the centre
Code the Orange of the Paint Editor
Code the Orange Script 2 of 2
Script 1 of 2 Orange Script 1 of 2
the original snowflake sprite
Orange

Script 2 on the orange Script 2 of 2


‘Down’ is a number set by the slider.
has a ‘Loop inside a Loop’. the Cloning Script
This is called a Nested ‘Across’ is also a number.
Loop. Here’s an
explanation.
Make copies.
How the Nested Loop works.
Each cloned ‘orange’ is
A Nested loop is a repeat loop inside another 30 pixels (steps) apart.
repeat loop. The dashed line highlights the Loop to copy each orange.
(Across) loop which is ‘nested’ inside the body of
the outer (Down) one. Then inner loop lays a first Pause at the end of a row.
row of oranges, moves down a shift and back the After each ‘Across’ the row
start of the second row. This is called the first pass shifts down by 30, and
goes back to the starting
of the outer loop. After the first pass, the oranges
x of -255 (middle of first
lay another row, down a shift and back to begin square in each row across) Cloning can be quite magical coding but,
the third row. Each pass of the outer loop triggers there are a few precautions
The arrow ends each outer pass.
the inner loop again. This repeats until the outer - create as few clones as possible
loop finishes. The sliders set the values Hide the original sprite. - delete a clone when it has finished
- to end, hide the original sprite

46 Rows of Oranges is shared at https://scratch.mit.edu/projects/438182528 Snowfall is shared at https://scratch.mit.edu/projects/438162702


Fun Palettes: Frogs on the Lily Pad
A Number Game for Young Children Seniors Coding for Juniors (1) Numbers Less Than 20
At this stage of your Scratch learning, a good way This Number game, Frogs on the Lily Pad is especially
to mark your achievement is to create an suitable for young children under 7 years. It will add
interactive game or resource which young children fun and interest to their Maths learning. Counting. costume 0
0
can play for enjoyment and also learn from it. You Partitioning and Combining numbers up to 20 are
might have great satisfaction and pride, if as a important number skill activities for this age group.
teacher, parent or senior student you see your These are essential, foundational Maths concepts. How many frogs do you
want in the Pond?
pupils, or your children, younger pupils or young To avoid unnecessary instructions, make full use of (not more than 18)
siblings enjoying the game you have programmed. the pictures, notes and the online shared project.
Make 3 variables: in Pond, on Lily Pad and Total
when clicked Script 1 of 3
Make a large display box with the three variables. when clicked on the Frog.
SCRATCH for Your Kids © Seamus O’Neill 2021

As the last action in the script is to hide, This is Script 2 of 3 0 + 0 = 0


show on the Frog.
The first thing is to make the sprite visible.
30 set on Lily Pad to 0 Place the
ask How many frogs do you want in total? (not more than 18) and wait
set in Pond to 0
0 display box
behind the
Frog Lily Pad Number input box
Understand this script
if answer 18 then
When the green flag is clicked the frog asks set TOTAL to 0
for a number not more than 18, and checks
say That’s more than 18. that the input is less than 19. This script sets all variables to zero

The Total and in Pond variables are both set


when the green flag is clicked. costume 16
16
to the input number e.g. 16 and send a broadcast
wait until answer 19 ‘set Total’ to tell the Number to switch to costume 16 (Script 2 on Number sprite).

The repeat ‘in Pond’ (e.g. 16) inside the dashed lines
set TOTAL to answer creates 16 self-clones (working copies) DRAG the
of the frog randomly located Script 3 of 3 on the Frog. frogs one
in the open area of the pond. The display box by one
set in Pond to answer
when I start as a clone becomes visible
Script 3 (the clone script), the
when the input
broadcast set Total instructs each clone to be display 2 + 14 = 16
visible, and draggable and show This is the clone script. box disappears box
when dragged to touch the
repeat in Pond
Lily Pad two variables change
Make a sprite with 19 costumes from
set drag mode draggable 12
to reflect 1 extra frog on the costume 1 to costume 18. Make the
Number
create clone of myself Lily Pad and one frog less (-1)
wait until touching Lily Pad
19th costume costume 0
costume 12
in the Pond. Each clone
set x to pick random 20 to 160 will be smaller by 30% Watch, record and Script 1 of 2 on
to save overcrowding change in Pond by -1 discuss the various when clicked the Number sprite
set y to pick random 0 to -60
on the Lily Pad. The partitions of the
clone will emit a Croak change on Lily Pad by 1 target number. switch costume to costume 0
sound.
change size by -30
say Now drop us onto the Lily Pad one by one. for 3 seconds when I receive set Total
play sound Croak until done Script 2 of 2 on
hide The actual (original) sprite gives the instruction to drag each switch costume to answer the Number sprite
cloned frog onto the Lily Pad. It must hide or be counted as an extra.

Frogs on the Lily Pad is shared at https://scratch.mit.edu/projects/445628330 47


Fun Palettes: Drag-a-Word
10 Steps to Creating the Game Seniors Coding for Juniors (2) Word Recognition
1 Animals: Get the sprites: chick, dog, lion, mouse, bear and frog. This Drag-a-Word Game is especially suitable for children under 7 years.
2 Make a Word Label: Choose Paint from the pop-up and to open The game idea is to drag a label with the animal’s name to a picture of the
the Paint Editor. animal. If the child is correct, the animal will react. To avoid unnecessary
instructions, make full use of the pictures, notes and the online shared
Use the Text tool. Use the default Sans project. Use the backdrop grid, by name Xy-grid-20px as a layout guide.
Start with the
longest name, Serif font and make
mouse. the text black.
mouse 4. Code label 1 sprite There is only one script on the word sprite 31
Draw a light coloured box behind the costume 1 is the word ‘mouse’
name. Group text and box to make a mouse A sprite in draggable mode can be
when clicked
word label sprite. label 1 moved by the arrow pointer when
playing the game in full screen. It is
SCRATCH for Your Kids © Seamus O’Neill 2021

Set the Rotation centre of the sprite. switch costume to costume1 necessary in this game to be able to
Name your sprite label 1. drag a word label to touch a picture.
set drag mode draggable
3 Costume 2: The label 1 sprite needs a second costume. Duplicate When the player drags the word ‘mouse’
forever to touch the picture of the Mouse.
the costume in the Costumes Editor.
x: -200 y: -150 is the position of this
if touching mouse then
1 duplicate 2 Delete the word and sprite at the start and at the finish

mouse export draw a tick mark in go to x: -200 y: -150 The label shows the tick
costume 1 costume 2
its place. when the words correctly touches
delete
the Mouse and returns
switch costume to costume2
to its starting position I’m a mouse
4 Code the label: You only need to code label 1. When you duplicate
label 1 the code will copy and you make small changes at the dots. broadcast squeaks
5 Use duplicate to make a total of 6 ‘Mouse’ labels else TOUCHING EEEK!
sprites
Under the stage, and depending on your device, right
click (or press and hold) on the label 1 thumbnail. go to x: -200 y: -150 mouse
mouse
Duplicate label 1 and make small changes in
label 1 Select duplicate and it will make a copy of the label 1 the code of labels 2 to 6 at the dots (step 8).
sprite with the name label 2. Repeat duplicating until X5
duplicate you have 6 ‘mouse’ labels. All the sprites will have the There is one script on the picture sprite
export same colour and size and will be numbered label 1 to 7. Code the picture sprite
What happens when the word
delete 6. All the labels will have the same code as label 1. Mouse touches the picture sprite?
when I receive squeaks
mouse mouse mouse mouse mouse mouse The broadcast makes the sprite play a
label 1 label 2 label 3 label 4 label 5 label 6 play sound squeaks until done squeak sound and also say “I’m a mouse”.
6 Space each label 80 px apart at y: -150 and Edit changes (step 8)
say I’m a mouse X5
mouse frog chick bear lion dog Squeaks

word mouse word frog word chick word bear word lion word dog
8 Open each label one by one in the Costumes Editor and make changes
7 Code the Mouse picture sprite with the short script. Drag copy (at the black dots) to the name, colour and x: position. Leave the ‘mouse’
the script to each animal picture and make small changes (step 8). unchanged. See the positioning and the full code on the next two pages.
Drag-a-Word is shared at https://scratch.mit.edu/projects/446619719
48
Fun Palettes: Drag-a-Word
How to Use the 20 Pixel Grid for Layout
180
9 Use the layout information in this picture to make The labels measure 3 squares by 1.5 and are spaced out 80
changes to the duplicates of the code on each picture 160 pixels apart. It is not necessary to be as exact with the
sprite and its matching draggable word sprite. You need animals as they are different shapes, but use the grid
to make the changes, where indicated by the black dots. 140 squares as a guide to sizing and positioning.

x: -180, y: 100 x: 0,120


y: 100 x: 180, y: 100
100

80
SCRATCH for Your Kids © Seamus O’Neill 2021

Chick dpg lion


60

Chirp
40
Bark Grunt

20

-240 -220 -200 -180 -160 -140 -120 -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 200 220 240

x: -180, y: -50 x: 0, y: -50 x: 180, y: -50


-20

-40

-60
Bear Mouse Frog

-80

Growl Completed Squeaks Croak


-100

10 To finish, change the backdrop. See the online project.


Completed -120

x: -200, y: -150 x: -120, y: -150 x: -40, y: -150 x: 40, y: -150 x: 120, y: -150 x: 200, y: -150
-140

-160
mouse frog chick bear lion dog
-180
word dog word frog word chick word bear word lion word dog

More ideas: See Drag-n-Drop Colour Game which is shared at https://scratch.mit.edu/projects/391372026


49
Fun Palettes: the Mouse, Muffin & Cat Game
3 Amazing Sensing Blocks Code on the Mouse
1. touching () script 1 of 2 on
SCORE 9 32 when clicked the Little Mouse
Little Mouse mouse-pointer Little Mouse
edge
show
Muffin On the front layer,
2. distance to () Cat go to front layer the Mouse is in front of
the Muffin
Little Mouse forever
is the Cat’s The Left and Right arrow keys
mouse-pointer
Cat
target move 3 steps have different purposes.
Little Mouse
Muffin
if key left arrow pressed? then
SCRATCH for Your Kids © Seamus O’Neill 2021

touching () and distance to () are used in the following turn 3 degrees


Go straight
Game. They each have a drop list with the names of for Muffin
The player guides the Little Mouse towards a
possible targets of the current sprite. At startup, when
Muffin that jumps around the stage. Every bite
there is only one sprite, the target is the mouse-pointer if key right arrow pressed? then
of the Muffin counts as a score with a bonus
and edge. When there is a second sprite, the target
score of 3 for every five bites. Every few Turn away from Muffin
can also include the name of the second sprite. turn 15
3 degrees
to avoid a Cat
seconds a Cat pops up ready to pounce on the
3. The attribute block, () of (), has two drop lists. The Mouse if it gets too close.
rounded drop list on the right is the target. At startup, if x position 240 then
when there is only one sprite, the target is the Stage. when clicked script 2 of 2 on
the Little Mouse if on the right edge of the
When there is a second sprite, the target can be either set x to -240
forever Little Mouse
stage go to the left edge
the Stage or the other sprite. The block is not used in
this Game. Mouse ‘touching cat’ also
next costume
means the Cat is touching Code the two missing if <> then conditional blocks
the Little Mouse. Same
backdrop # wait 0.1 seconds result, Game Over! that instruct the sprite on what to do if on the left
backdrop name edge (x: -240) or on the top (y: 180) of the stage.
volume if touching Cat then
my variable The last block above sets the Mouse sprite to x: -240 if the
Little Mouse Muffin sprite’s x: is greater than x: 240. The block after that should be,
stop other scripts in sprite if the sprite’ x is less than x: -240 to set x to 240. Also, on the
vertical plane, the last block below sets the sprite to y: 180 (top
broadcast Game Over of the stage) if the sprite’s y: is lower than y: -180. The 2ⁿd last
block should be, if the sprite’s y is greater than y: 180 to set y
x position In the Mouse, Muffin and Cat game each
say It’s Game Over for 3 seconds to -180 (send to bottom of the stage). Code the missing blocks.
y position sprite can access information about each
direction other with this extraordinary block. The
costume# picture shows the Cat as the target. The say join Your Score is SCORE for 3 seconds if y position -180 then
costume name Mouse and Muffin have access to the Cat’s
size listed attributes. The Cat’s listed attributes if on the bottom of the
stop all The script stops AFTER announcing the SCORE. set y to 180
volume are its x: and y: position, its direction, stage, go to the top
costumes info, size and volume (sound). This
is information that could be used in the
Mouse and the Muffin sprites’ code.

50 the Mouse, Muffin and Cat is shared at: https://scratch.mit.edu/projects/443727887


Fun Palettes: the Mouse, Muffin & Cat Game (continued)
Code on the Muffin Code on the Cat

Create the variable script 1 of 3 on Understand the code on the Cat:


the Muffin script 1 of 3
SCORE. It can be on the Cat
(Script 1) At start up, the Cat remains
on the script of any hidden for 5 seconds until it clones it
Cat
sprite in the game Muffin
deletes after a further 5 seconds. This
(it’s not necessary will continue until the game is over. (Script 2 is the
The original algorithm for each clone); go to a random position
that the SCORE Muffin has
variable should be 2 costumes.
and show. Change to a new random position as long
on the Muffin). This one has 5. as you are greater than 70 steps from the Mouse.
Each has one Keep pointing towards the Mouse. If for any second
bite more you are less that 70 steps from the Mouse, move at
script 2 of 3 on
SCRATCH for Your Kids © Seamus O’Neill 2021

out of it than
the Muffin
the next.
a rate of 2 steps to pounce.
After 5 bites This is a game of chance. The
the player likelihood is that the Muffin will
gains 3 bonus points and
pop up beside a cat, the Mouse
the Muffin is restored to
costume 1 again. will get too near it and be caught.

Understand the code on the Muffin: script 2 of 3 on the Cat


(Script 1) The Muffin does little else
than pop up in random positions
anywhere on the stage every 5 seconds.
This makes it difficult for the Mouse to
touch (take a bite of) the Muffin. (Script
2) When the Mouse is successful, we
hear a chomp sound, there is less
Muffin but the SCORE increases by 1. To
keep the sprite’s original size intact, in
this game the muffin is on a plate.
(Script 3) When the Mouse is caught by
the Cat it broadcasts the message
Game Over, which hides the Muffin
and stops all its scripts.

script 3 of 3 on the Cat

(Script 3) When caught, the


Mouse will broadcast, Game
script 3 of 3 on the Muffin Over and the Cat will hide
and stop all its scripts, like
the Muffin also does.

51
Fun Palettes: Lists
List Blocks Fill a List Directly Fill a List by Answering Questions
Code Costumes Sounds A variable can store only one piece of data at a
Code Costumes
time. A list can store many items of data all at Sounds
33
Make a List once. Each item of a list can be identified by its
place number, e.g. item 1 etc. To fill a list directly 1 Create this New Sprite
Motion
just click the + and enter the data. You can also This is a very unusual Sprite. It has
New List
fill the list using the insert block. Data in a list can costume 1
a different animal for each costume.
Looks be either number or string data. Here the comma 2 Get the crab from the Sprites library
New list name: is string data. It is not common to mix data types. and delete costume2. Rename the
Count in Sevens The number of items in a list is called its length. costume 2 crab to Animals. In the Costumes
Sound library (see p.21) get 9 more animals
For all sprites For this sprite only 3
and add them as Animals sprite
SCRATCH for Your Kids © Seamus O’Neill 2021

Count in Sevens Count in Sevens


OK
costume 3 costumes. Code the sprite with
Events Cancel
(empty) 1 7,
4
these two short scripts.
2 14,
My List costume 4
Control 3 21,

add thing to My list 4 28, 5


Animals

Sensing 5 35, costume 5


delete 1 of My list x
6 6

Operators
delete all of My list + length 0 = + length 6 = costume 6

7
Variables When you have filled the list with 12 items …
insert 1 at 1 of My list
costume 7
7, 14, 21, 28, 35, 42,
49, 56, 63, 70, 77, 84 8
My Blocks replace item 1 of My list with 1 Create a New List, Creatures
costume 8
the name
item 1 of My list say Count in Sevens Creatures will Creatures
9
help you to
distinguish (empty)
item # of thing in My list 28 costume 9
the list from
10
the Animals
length of My list sprite.
say item 4 of Count in Sevens costume 10
My list contains thing ? Don’t fill the
list directly.
12 You will fill it
show list My list by answering
Extensions
the Cat’s + length 0 =
picture quiz!
hide list My list say length of Count in Sevens

Cat The Cat’s quiz script is on the opposite page

52 Names of List blocks: list reporter; add() to ; delete () ; delete all ; insert () at () ;
replace item () with () ; item (); item # of; length of; (list) contains ()?; show; hide;
See Animal List at
https://scratch.mit.edu/projects/438075982
Fill a List from Answers (contd.) Fun Palettes: Text in Lists
To start, the Creatures list is empty. The Spell-a-Word
Animals sprite displays costume 1, which when clicked Word as list

is a picture of the crab.


say I’ll make what you type into a list of letters. Cat
The code in the repeat (10) loop asks the
name of the animal in the picture and
speak I’ll make what you type into a list of letters.
broadcasts the Animals sprite to display
its next costume. It also adds the answer say I’m a clever cat. I will then spell the word.
to the Creatures list. To keep the code
easy to understand, there is no check on speak I’m a clever cat. I will then spell the word.
the spelling or even if the answer is
correct.
SCRATCH for Your Kids © Seamus O’Neill 2021

carrot
delete all of Word as list Clear your list at the start

when clicked Cat set letter number to 0 variable = 0 A headset is recommend, although the
speak code is not absolutely necessary.
ORDER:
delete all of Creatures speak Type the name of any vegetable.
the ask must

repeat 10
be before the
broadcast ask Type the name of any vegetable. and wait Type the name of a vegetable.
34
ask Name the animal. and wait repeat length of answer Example: If you type carrot (6 letters),
length of (answer) = 6,
broadcast ask Question and wait change letter number by 1 the change by 1 and insert will repeat (6) times
the 1st letter

add answer to Creatures insert letter letter number of answer at length of Word as list + 1 of Word as list

finally, the cat says if your word is ‘carrot’ this code will insert ‘c’ 1st place in the list by name Your word
the full list of animals.
say Creatures set letter number to 0 In this project, the name of the list is Word as list (your
There are no commas
to separate the names input word) and the variable is letter number. If you
as that adds an extra repeat length of Word as list input a phrase, the space will count as a letter e.g.
Creatures complication. ( It would
be easy if input answer
Brussels Sprouts would count as 16 letters!
1 crab change letter number by 1
were to finish with
2 rabbit a comma.) The List and Variable blocks are grouped together in
say item letter number of Word as list
the Variables palette, because they are often used
3 chick together. One way to fill a list is to have a variable
speak item letter number of Word as list to feed items into it.
4 fish
5 fox Always start with delete all and with the variable set
c-a-r-r-o-t
6 mouse x say Word as list at zero. The length of (answer) sets the length of the
continued: list. The insert block adds letter 1 to the list at length
+ length 6 = giraffe, penguin,
speak Word as list of list +1 because the list is zero in length after the
lion, beetle
delete all. The plus 1 adds the letter as item 1.
Spell-a-word is hared at https://scratch.mit.edu/projects/438083231 53
Fun Palettes: A Game of Luck with an Invisible Sprite
New Sprite & New Costume
Fly sprite: There is no fly in
Code Costumes Sounds the Sprite library, but it is
1
quite easy to create your
Costume costume 1
Group Ungroup Forward Backward Front Back own. The fly will buzz
Costume1
Fill Outline 1
around, while the frog’s eyes
Copy Paste Delete Flip Horizontal Flip Vertical follow its movements. When
it approaches the invisible
‘X’ sprite, the frog’s tongue
will shoot out to eat the fly.
1. Paint (Create new) a Fly Sprite A variable will keep track of
the flies eaten in 30 seconds.
SCRATCH for Your Kids © Seamus O’Neill 2021

Frog sprite: This frog sprite


has only one costume - with
Paint extended tongue. Duplicate fly frog left eye right eye invisible

it and delete the tongue on The invisible ‘x’ marker sprite: Use ghost effect
costume 1. on the X-Button from the Sprite library to mark
an invisible spot on the stage at the tp of the
1 frog’s extended tongue (costume 2)
Open the Paint Editor to paint (create) a new sprite. Draw a fly out of duplicate
three ellipses. Position the fly’s nose at the centre of the canvas. frog Code the Invisible Sprite
export
2
Code Costumes Sounds delete
frog 2
invisible
35
1 Costume costume 1
Group Ungroup Forward Backward Front Back
1 Script
Frog’s eye sprites: Make two
frog
Fill Outline 1 duplicates of the frog and
Copy Paste Delete Flip Horizontal Flip Vertical
2 delete everything except the
left eye for one sprite and the
frog 2
2. Give the Frog a New Costume right eye for the other. Snap
with no extended tongue. the rotation centre of each
eye sprite to the stage centre. Create two variables: Name one variable Flies
Name costume 1 is no tongue. (See page 14). The eye sprites Eaten and name the other Timer.
Name costume 2 tongue should be the same size as
set Flies Eaten to 0
the frog’s eyes (at 200%)
The two eye sprites will go
Flies Eaten
on top of the frog’s eyes and timer
Choose a Sprite their code will make them Rename variable
point continuously in the Delete the “Flies Eaten” variable
direction of the moving fly.
Frog and Fly project https://scratch.mit.edu/projects/254019771
54
Code on Fly (2 Scripts) Code on Frog (3 Scripts) Code on the Left Eye Sprite (1 Script)

when clicked when clicked when clicked


frog left eye
show fly set Flies Eaten to 0 forever
the left eye is larger
than the right.
go to random position set size to 200 % point towards fly the size of the two eyes
should also be 200 to
the fly will be in front 1
go to front layer switch costume to no tongue to match the frog’s eyes
of the frog’s tongue
frog
the code on both eyes is identical. When one eye is coded,
forever
SCRATCH for Your Kids © Seamus O’Neill 2021

just drag-copy the code to the second eye


the frog’s tongue action
the path of the fly
move 30 steps Code on the Right Eye Sprite (1 Script)
is random
when I receive snap
turn pick random -30 to 30 degrees
2 when clicked
switch costume to tongue right eye
if on edge bounce the sprite is not hidden
frog 2
forever the two eyes should be on
change Flies Eaten by 1
top of the frog’ eyes so that
if touching invisible ? then the eaten flies add up it looks like the frog is
0.2 seconds point towards fly
wait following the path of the fly
broadcast snap snap is received by 2 sprites 1

switch costume to no tongue frog set drag mode draggable


to help position the eye
the sender (fly) and sprites above the frog’s eyes,
it’s not necessary that drag make the eye sprites draggable so you can move them into
the frog (to change the variable) the timer is coded on
when clicked
position in Full Screen view.
the frog.
Summary
the fly is eaten by the frog set timer to 30
This is a game of luck. The fly will accidentally touch the
when I receive snap forever invisible X sprite which is located at the tip of the frog’s
tongue. To give the impression that the frog has eaten
as each second passes
hide
snap is received by the sender (the fly) wait 1 seconds the seconds decrease it, the fly disappears and re-appears a second later.
The game timer is set to last 30 seconds, but you can
wait 1 seconds change timer by -1
change that to longer or shorter.

go to random position if timer 0 then


Timer: The wait (1) second and change (timer) by (-1)
second are an essential part of a timer. So also is timer
go to front layer = 0 which calls full time and engages the stop all block
stop all
If you want to make the frog eat more flies, make the
show invisible sprite bigger, so the fly touches it more often.

55
Fun Palettes: Pong Game for a Single Player
A Game that Uses All the Palettes Brief Notes and Suggestions
This Pong Game is played by a single player who must Make two variables Score and Timer. Instead
make the highest possible score before the timer runs of playing for 30 seconds, you could make the
out or by the time the Ball touches the red bar. game longer by increasing the ‘set timer to’
36 more than 30 (whatever suits). Also, if you
Pong is played with a paddle, a ball, a WIN sprite and
a red bar along the bottom of the background. The Ball want higher scores, you could increase the
bounces off the 3 sides of the stage or the player- ‘change score by’ for each touch of the Paddle
controlled Paddle. The player can only move the paddle with the Ball (e.g. by 5)
sideways. If the Ball touches the bottom red bar the Read the Advanced version note below for a
game is over. The player wins, if the timer reaches zero. more difficult version of the game
The Paddle is about 4 grid squares (80 pixels
SCRATCH for Your Kids © Seamus O’Neill 2021

when clicked This is script 1 of 2 in width and about 20px high. Make sure you
A headset is align the paddle’s Rotation point with the
There are 3 sprites. You
set score to 0 recommend. can get the Ball in the centre of the canvas.
Paddle Win Sprite library and make The WIN picture is made up from the
set y to 160
Get the Ball in the Ball
the Paddle and WIN
Sprite library sprites in the Paint Editor. Get the Blue Sky backdrop and
hedgehog sprite and letter sprites!
turn 20 degrees draw the red bar in the backdrop Editor.
There are two
scripts on This is script 2 of 2 on the Ball
when clicked There is only
go to front layer Ball the Ball
when clicked one script on
the Paddle
forever
forever Paddle
Why not code the collision set timer to 30 Ball Draw a Paddle
move 10 steps between Paddle and Ball by set y to -160 Set x to (mouse x) constrains
touching the color of the the Paddle horizontally.
repeat until timer 0
Paddle? It’s an option. set x to mouse x Set y: to -160 constrains it
if on edge, bounce
vertically to just above
wait 1 seconds the red bar.
if touching Paddle ? then
change timer by -1 Create your own WIN sprite
turn 180 degrees

start sound Pop when clicked


broadcast show win
Win
change score by 1 Advanced version: hide
stop all There are two
In the advanced version linked scripts on the
WIN sprite
below, code which makes the game a little more
if touching color ? then when I receive show win
exciting, is added to the stage. It is not timer
The red bar is not a sprite but you could based. Instead it sets a winning score of 100, but
stop all show
make it a sprite to give a different option.
also gradually increases the speed of the ball and
makes its bounce from the Paddle less
play sound Xylo4 until done
predictably by turning it random degrees.

56 The above version of Pong Game is shared at https://scratch.mit.edu/projects/447241141


For a more advanced version go to https://scratch.mit.edu/projects/447241957
The Bat Catcher Ghost is on the prowl for bats in the
eerie moonlit wood. How many bats will he catch?
It’s up to you as you go for a high score. There are
several ways to move the Ghost to chase the Bats.
You could use the direction keys on the keyboard or
use Up, Down, Left, Right direction sprites. The
method used here is probably the easiest way to
SCRATCH for Your Kids © Seamus O’Neill 2021

play on tablets and hand-held devices. Just move 37


the mouse pointer and mop up the bats.

Score 9

Script 1 of 2 Script 2 of 2 on
when clicked
on the Stage the stage creates
background music
set Score to 0

when clicked set Count down to 60


Ghost
Ghost

set ghost effect to 50 repeat until Count down 0


when clicked

set size to 50 % wait 1 seconds


forever

Script forever change Count down by -1


set x to mouse x
1 of 2 Script
go to front layer
on the set y to mouse y
2 of 2 if Count down 0 then

Ghost next costume


on the
stop all
Ghost
Move the Ghost with wait 0.25 seconds

the Mouse pointer

Continued next page 57


Fun Palettes: the Bat Catcher Ghost Game
Add Variables Code to the Stage Code the Bat Sprite with two Scripts
Get the Bat and Ghost sprites and the Woods
backdrop from the libraries. Code the Ghost with Script 2 of 2:
when I start as a clone the bat clone script
the two scripts from page 55. Script 1 moves the when clicked
Ghost with the Mouse pointer. Script 2 codes the Bat set size to pick random 30 to 40 %
Ghost’s size and transparency and brings it to the show This is Script 1 of 2 on the bat.
front layer while animating its costumes. go to random position The clone acts as if it is
set rotation style left-right an independent sprite.
Make 2 Variables on the Stage
show
The STAGE icon is under the stage on the right. set size to pick random 30 to 40 %
Click the small picture of the Woods backdrops
to open the tab to Code the Backdrops (Stage). forever
forever
SCRATCH for Your Kids © Seamus O’Neill 2021

Code Backdrops Sounds move pick random 6 to 10 steps


move pick random 6 to 10 steps
When the Stage (Backdrops tab) is selected you next costume
next costume
will notice that there are no Motion blocks (you
can’t move the stage). However, most other wait 0.1 seconds
wait 0.1 seconds
blocks can be used to code the stage. You can
programme variables and music on the stage. change y by pick random -10 to 10
change y by pick random -10 to 10
Make a Variable with the name Score. The code
if on edge bounce
on page 55 sets the Score to zero and increases if on edge bounce
it by one, each time a Bat touches the Ghost (See
if touching Ghost ? then
script 1 on the bat). Make a second variable with if touching Ghost ? then
the name Countdown. Set Countdown at 1
change Score by 1
minute (60 seconds). Set its value to decrease change Score by 1 The dashed lines
by 1 as each second passes for one minute. highlight the
delete this clone
create clone of myself clone command
Code background Music on the Stage and the code
that executes
Code Costumes Sounds hide the behaviour
of the clone. When the cloned bat touches
Script 2 of 2 on the Stage wait 3 seconds the Ghost, it increases the
The ‘hide’, ‘wait’, ‘go to random position’ Score by one, then it is
when clicked The Sound library is at the and ‘show’ sequence, simulates the Ghost deleted, so that there is no
bottom of the open Sounds tab. go to random position capturing the bat. The original bat build up of clones.
Choose the Loops category and disappears for 3 seconds when it
set volume to 20 % select Cave. Set the volume low reappears in a random position. The
and code the volume to reduce show cloned bat behaves just like the original.
forever after each round it plays.
Bat

play sound Cave until done You can have several bats on the stage duplicate

It will fade out fully but you only have to code one. When export
change volume by -2
after 10 rounds. the bat is programmed you can make delete
duplicates. Code is copied in a duplicate.

58 Bat Catcher Ghost is shared at https://scratch.mit.edu/projects/428146314


THE FUN PALETTES Sensing Blocks
Situation 1: Cat Comes to Town Use a sprite as an Invisible Marker
Situation 2: Dog at the Hen House
scratch.mit.edu/projects/379928715 scratch.mit.edu/projects/379923376
The cat comes into the town from the The dog is prowling around the Chicken run. He enters
left side. He walks past the door of the on the right and leaves the stage on the left (Opposite
shop, meows and exits on the right. He of Situation 1). The dog barks each time he passes the
repeats it over and over. How do you hen house. How do you make the dog bark just exactly
make the cat Meow just exactly at the at the hen house? One way is to use an invisible marker
door? One way is to use an invisible X sprite as in Situation 1. Another way is to use the
marker sprite. touching color block. There is yellow grass to the left of
the door. Use the eye dropper and the Fill sliders to get
Script on the Marker
the yellow grass colour. The colour occurs once on left
SCRATCH for Your Kids © Seamus O’Neill 2021

and once on right. The dog should bark twice!


Events marker

An invisible sprite is not the same as a Color


touching color ?
Looks hidden sprite. I’ve used the Button5 sprite
Saturation
from the library but any sprite will do. Use
The invisible X marks the position of the door
the ghost effect, not the hide block. I’ve Brightness
made it very small in the sprite info box.
I’ve also reduced the Cat’s size to 60%.

the Sensing Script A headset is


recommend.
Script 2 of 2 on the Cat
An easy way to code Situation 2, is to Save Situation 1 as
a copy. Rename the copy project as Dog at the Hen House.
Get the Dog and Farm from the libraries. Just drag the cat's
two scripts of code to the dog’s thumbnail. Make the edits
and delete the cat and marker sprites.
the Edits A: Script 1 of 2 on the Dog should have …

59
THE FUN PALETTES Need Operators (Light Green)
Play Around with Play Around with the
What You Need to Know About
the Number Operators Basic Relational Operators
the four basic Maths operations ‘less than’ ‘equal to’ greater than’
1 a single operator plus
‘add’ ‘subtract’ ‘multiply’ ‘divide’
Type numbers less < 50 8 5 = 13 > 50
3 5 than 20 into the 6 3 6 3 6 3 6 3
plus operator. Click
to get its value. true true false
9 3 18 2
8 e.g. 5 + 3 = 8
‘addition’ ‘subtraction’ ‘multiplication’ ‘division’ These have a different shape and serve a different purpose.
‘plus’ ‘minus’ ‘times’ ‘divide by’ Read what’s on the block from left to right to compare the
2 a single operator in the say () block. ‘total’ ‘take away’ ‘by’ ‘into’*
value on the left of the sign with the value on the right. They
Each has a sign or symbol and vocabulary report only true or false. Think of the less than and greater
13
SCRATCH for Your Kids © Seamus O’Neill 2021

say 2 11
We can only manage two numbers at a time, than signs as like the jaws of a crocodile. Snapping jaws
one on the left of the sign and one on the making bigger bites. Crocodile jaws always face to the
Click to make the right. Even though there are no words we BIGGER number. The Croc’s body is always on the smaller
sprite say its value. read the expression from left to right. It’s OK side of its great jaws.
to switch around the plus and multiply smaller smaller
3 plus, subtract, multiply, divide numbers but NOT the subtract and divide greater

Use any single operator and get a value numbers. We usually write multiplication when this sprite clicked
with x as 2 x 5 and division with a dot above Input numbers
8 2 2
7 a dot (like a fraction) as 10 ÷ 2. Calculators, ask Click me and input a number and wait between
keyboards and computers use the ‘asterisk’ 0 and 20.
6 2
14 for multiplication and ‘slash’ for division. forever Which numbers report true
*NB: Be careful when you use the word ‘into’ and which report false?.
say 10 5
when reading division. Why? You switch say answer 11 The hexagon shape
around the sense and get a different value. slots into the round
Click to make the sprite say its value. So 10 ÷ 2 is NOT ‘10 into 2’ but ‘2 into 10’! say () input window.

4 combinations plus, subtract Thinking with the Operators You have 5 sweets left
plus inside
a minus
2 6 Six white eggs, 2 brown eggs and 3 of
them broken. Forget about eggs and See it at:
7 4 gives this 7 4 2 think only numbers https://scratch.mit.edu/projects/477516868
6 2 3
using Scratch.
Use the say () block also 9 say join join You have 8 3 2 4 sweets left.
5 (6+2)-3
5 combinations 1
5 3 7 I had some sweets. 8 were
say join join apple banana banana
16 chocolate and 3 were caramel. Jen
“(space) sweets left.”
took 2 sweets and Jan took 4. Forget
say 5 3 1
about sweets, chocolates, caramels. ( 8 + 3 ) - ( 2 + 4 ) “You have (space) ” 8 3 2 4

Make the sprite say its value. You do the thinking. Let Scratch do the Maths. Use a combination of text (string) and number data.

60

You might also like