Event-Driven Programs

In the good old days, computers didn't have things like a mouse or a graphics display.
Back then, everything happened sequentially - in clear steps, one after another -
like the rabbit hopping to the cell phone.  Every time you run the program, the same list of actions occurs.

- Events -

An event is something that controls the computer, like a mouse dragging or clicking,
or the user pressing a key on the keyboard.  In event-driven programs, there is
no pre-written list of actions that should occur, e.g. no story-line.  Instead, the program
responds to mouse-clicks and key-presses, whenever they occur.

The Penguin Tutorial #3 starts with a pre-written set of actions, playing a specific song.
But then you will change it so the notes are played when you click on each penguin.
That means there is no pre-programmed song - instead, the  user takes control.

img1.gif

Even in event-driven programs, it is still useful to write methods to automate the responses
to a user action.  Then, instead of doing all the mouse-clicks to play a song, the user could
click on a short-cut to play an entire song.

- What to do Today -

  1. Do the penguin tutorial - Tutorial #3.  
  2. The Penguins a..r..e..  t....o...o...  s......l.....o.....w.  We gotta make them faster.
    Click on each penguin (top left), then on the singNote method's [edit] button.

         img2.gif    img3.gif

         Now in the [play sound] command, click on [more...], select duration and set it to 0.25 sec.
         
If you wish, you can set it to an even shorter amount of time. You need to do this for each penguin color.
         Then they will respond more quickly.

         You can also make them open and close their mouths more quickly.  The speed is controlled by the [howFast] parameter.
         Change the 0.12 to a smaller number (like 0.02).  This is still too slow for a real pianist, but at least it's better.

  1. Now record a short song - e.g. Jingle Bells, Row-row-row Your Boat..  Keep it short, under 20 notes if you can.
    You need to take notes about which Penguins you "played" - you need this for the next step.
     
  2. Change the World.penguins sing song to play YOUR song.  That means you need to edit the sing song  method,
    and change both the colors of the penguins (e.g. notes) and the wait commands to make the notes play at the right speed.
    You need a [Do in order] block for each note you played.

    img4.gif 
     
  3. If you finish all this before the end of the period, you should watch this video
    and find out how to display a picture in Alice.

          http://www.youtube.com/watch?v=_QMt72ysUB4