-
Now let's learn about a programming concept
called Events.
-
An event tells your program to listen for
something to happen, and then react right away.
-
Some examples of events are: listening for
a mouse click, an arrow button press,
-
or atap on the screen.
-
We use events all the time as humans, when
we respond to different signals.
-
When I'm walking down the street, and see
someone else walking towards me, I check to
-
make sure I'm wearing my mask correctly.
-
When we develop a simulation, we create a
series of rules.
-
For this simulation, we'll code this rule:
When a healthy monster touches a sick monster,
-
the healthy monster will become sick.
-
Here is a "when touches" event.
-
Click the small blue plus sign here, on this
block.
-
It will show 2 new blocks called Subject,
and Object.
-
Drag the purple monster block, into the code
below it.
-
This code is telling the computer that when
a healthy monster meets a sick monster, the
-
healthy monster will change its costume, to
look like a sick monster.
-
Click "run" to watch your simulation play
out.
-
Run your program a few times, and observe
the differences.