Raspberry Pi A User Manual page 186

Hide thumbs Also See for Raspberry Pi A:
Table of Contents

Advertisement

170
Figure 11-10:
The completed
code for the
simple Scratch
game's cat sprite
If you move the cat towards the Cheesy-Puffs with the right-arrow key on the keyboard, the
game starts. When the cat reaches the Cheesy-Puffs, the dialogue exchange takes place and
the bowl should disappear.
Although this example is effective for introducing some important programming concepts,
it's hardly the best way the game could be coded. Scratch includes a message broadcast system
that allows code attached to one object to communicate with code attached to another,
which enables you to create much neater collision results that don't rely on carefully timed
pauses in order to make sense.
To experiment with broadcasting, try using the
from the Control palette. A message created for a broadcast block in any object can trigger
code in any other object using the
multiple objects and their code together.
P A R T I I I
P R O G R A M M I N G W I T H T H E R A S P B E R R Y P I
broadcast
flag, meaning you can use it to link
when I receive
and
when I receive
blocks

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for Raspberry Pi Raspberry Pi A

This manual is also suitable for:

Raspberry pi b

Table of Contents