Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs.

Similar presentations


Presentation on theme: "Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs."— Presentation transcript:

1 Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs

2 Fall 2007ACS-1805 Ron McFadyen2 Events We say an event occurs when something significant happens. Alice provides for handling many different kinds of events … examine the upper right hand pane of the Alice interface. Notice that we have been using the first event type in all of our programs

3 Fall 2007ACS-1805 Ron McFadyen3 Events Each event is paired with an event-handling method By default when the world starts is associated with my first method

4 Fall 2007ACS-1805 Ron McFadyen4 Events User-generated events can defined for when the user clicks the mouse or types a key on the keyboard. This allows for interactive programs … methods will execute in accordance with user input.

5 Fall 2007ACS-1805 Ron McFadyen5 Parameters Methods may be defined with parameters. Certain events (e.g. mouse click) are associated with an object and can be useful for setting up values to be passed as parameter values. Text example 1: use clicks on a person to be saved by a fire truck. The person object, the floor they are standing on, and the distance are passed to the method. One event-handling method works for all 3 objects.

6 Fall 2007ACS-1805 Ron McFadyen6 Parameters Text example 2: Simulation of a Greek Tragedy The storyboard is more complicated… the event handler calls three other methods. Because the method is directing all the action for the user click, it is referred to as a driver Using a driver is a common technique for organizing complexity… a common outcome of stepwise refinement.

7 Fall 2007ACS-1805 Ron McFadyen7 Tips/Techniques Events When the world starts… we have always used this one When a key is typed… chapter 5 When the mouse is clicked on something… chapter 5 While something is true… see chapter 7 When a variable changes … see chapter 10 Let the mouse move … event handler exists in Alice Let the arrow keys move … event handler exists in Alice Let the mouse move the camera … event handler exists in Alice Let the mouse orient the camera… event handler exists in Alice Take care with these – you may end up seeing nothing User can move objects about


Download ppt "Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs."

Similar presentations


Ads by Google