This Scratch tutorial uses the broadcast and receive code blocks. We will have 2 sprites on the stage with the one sprite reacting to the other when they bump into each other.

Scratch Cat

In this program, we have two sprites: Scratch Cat and a Pufferfish. Using almost exactly the final code from the Sensing in Scratch tutorial, we start with the code below for the Scratch Cat:

Screenshot of the Pufferfish program in Scratch.
Screenshot of the Pufferfish program in Scratch.

Broadcast

The code from step 1 (for Scratch Cat) needs one block added, the broadcast block.

Screenshot of the Pufferfish program with a broadcast code block in Scratch.
Screenshot of the Pufferfish program with a broadcast code block in Scratch.

Pufferfish

The Pufferfish sits in the path of Scratch Cat. Like any pufferfish, this Pufferfish will puff up angrily when something bumps into it.

  • The Pufferfish has a total of 4 costumes
  • Use the change size by block in combination with the switch costume block to make Pufferfish swell as well as huff-and-puff
  • Add the above to a loop

Receive

Screenshot of adding the when I receive block in a Scratch program.
Adding the when I receive block.

When Scratch Cat touches Pufferfish, he broadcasts a message that can be received by any other sprite in the program. All we need to do is add the when I receive block to the Pufferfish sprite code.

Finishing touches

Adding the finishing touches to the Pufferfish Scratch program.
Adding the finishing touches.
  • Once the loop has puffed our Pufferfish up, use the set size block to return it to 100% of its original size.
  • Add a little change of expression — once the Pufferfish has calmed down he gives a little wink.
  • As the Pufferfish program is finished, add a stop block and set it to this script.

Motion

Looks

Sound

Events

Control

Sensing

Operators

Variables

My Blocks

By MisterFoxOnline

Mister Fox AKA @MisterFoxOnline is an ICT, IT and CAT Teacher who has just finished training as a Young Engineers instructor. He has a passion for technology and loves to find solutions to problems using the skills he has learned in the course of his IT career.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.