Topic #1 for our Intermediate Scratchers this week was using the broadcast blocks to control the flow of action in our code. In our last set of classes, I’d watched the students try to control flow through other events: key presses, waits, background switching, etc. So I knew they’d be excited to learn this method and be able to trigger events from within their code.
Our plan was to make a Surprise Party project. Our “guest of honor” sprite enters a dark room. He asks where everyone is. The lights come on to reveal a party and all of the guests shout “Surprise!” Our broadcasted message comes from the guest of honor sprite after he asks his question. The guest sprites and the backdrop are all waiting to receive the broadcasted message and react.
To start the background is dark, and the guest of honor sprite glides across the screen and asks, “Where is everybody?”
Our next block broadcasts a message.
The backdrop code receives the message and switches to the Party backdrop.
Each of our “guest” sprites, who were previously hidden, receives the message, shows themselves, and says “Surprise!”
Here it is in action:
And then, just for fun, I challenged them to turn it into a party! Dancing, color changing, cake & party hats, the happy birthday song — they had some great ideas!
Now that they know how to broadcast messages in their code, we can really build on it and add some complexity to their projects!
Scratch project page can be found here.