Return to Video

Outbreak Simulator: Events

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

more » « less
Video Language:
English
Team:
Code.org
Project:
Hour of Code
Duration:
01:26

English subtitles

Revisions