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.
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 -
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.