6. Get into the Story (events)

In all of the programs/worlds you've written so far, you have taken the role of the screen-writer. You have specified, in advance of the program actually running, how objects should move, what they should say, and so on. The Alice system has been the director, ensuring that when the "theater performance" starts, all the "actors" perform their parts as you indicated they should.

As in most movies and theater, the audience watching your program execute hasn't been able to interact with the action, other than cheering or booing from the sidelines. They are simply observers, just as you are when you sit in a movie theater.

We're going to change all that in this chapter...

Things you will learn in this module:

    1. What events are, and how you can work with them to enable your audience to interact with your program - to create interactive animations, or games.
    2. That there are a number of different kinds of events, enabling your users to interact with your programs in different ways
    3. Finding out how the code you write to respond to an event can, in some situations, be reused to handle many other events.

Vocabulary for this module:

Event: Something that happens externally to your program, often initiated by your audience - the users of your programs.

Event Handler: This is a connection that you make between one or more particular events and code (a method) you have written in your program. The connection and the code together enable your program to respond to the events occurring outside your program.

Key Press Events: These are events that occur as a result of the user pressing keys on the computer's keyboard.

Mouse Press Events: These are events that occur as a result of the user manipulating the mouse - there are events for pressing and releasing the buttons on the mouse, as well as for whenever the mouse moves.

Get Started! >>