Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.

Similar presentations


Presentation on theme: "Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition."— Presentation transcript:

1 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition by Tony Gaddis Chapter 7: Events

2 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Responding to Events Event Action that take place while a world is playing Alice worlds detect events and respond to them For example: when a user clicks an object with a mouse…it’s an EVENT! when a user types a key on the keyboard…it’s an EVENT! 6-2 6.1

3 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Alice Events Process of responding to an event is called handling the event Tile for an event MUST appear in the Events Editor When world is first created, the event when the world starts appears in the Events Editor 6-3 6.1

4 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Alice Events Most event tiles require that additional arguments be specified The method that is executed in response to the event is called the event handler 6-4 6.1

5 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Alice Events When the world starts While the world is running When a key is typed While a key is pressed When the mouse is clicked on something While the mouse is pressed on something While something is true When something becomes true When a variable changes Let the mouse move Let the arrow keys move let the mouse move the camera Let the mouse orient the camera 6-5 6.1

6 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Specialized Events Some events from the previous list do not appear in the Events Editor General event must first be created Right-click and select change to Changes an event to a specialized event 6-6 6.1

7 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Handling Key Press and Mouse Events Alice can detect when a key on the keyboard has been pressed Key Press Events (such as when a key is typed) The event is triggered when the user types a key Key that will trigger the event must be specified any key is the placeholder until the “real” key is selected 6-7 6.2

8 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Handling the While a key is pressed Event The event occurs as long as the user holds down a key This tile has four different placeholder slots: any key Begin During End Known as BDE event 6-8 6.2

9 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley BDE Event Begin Specifies an action to take place at the beginning During Specifies an action to take place during the event End Specifies an action to take place at the end (when the event stops occurring) 6-9 6.2

10 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Task #1 Complete tutorial 7-1 on page 276 called Handling key press events along with Tutorial 7-2 on page 280 called Handling the while a key is pressed event. 6-10

11 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Mouse Events / While the mouse is clicked… When the mouse is clicked on something Event is triggered when the mouse is clicked on an object in the world While the mouse is clicked on something Event occurs as long as the user holds down the mouse button while the pointer is positioned over an object 6-11 6.2

12 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Task #2 Students will explore mouse click events on pages283-284 by completing Tutorial 7-3 called Handling a mouse click event. Design a simple world that utilizes two of the following 1)Handling a key press 2)Handling the while a key is pressed(BDE) 3) Handling a mouse click. You decide the characters or objects just ensure that two of the three items are used from above. 6-12

13 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Using Events in Simulations and Games Programs can have numerous events They respond to various user interactions and internal events Note the various events that appear in Island Rescue 6-13 6.3

14 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Task #3 Open Up Globe in the books example programs and see the While the mouse is pressed on something event. 6-14

15 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Tips for Games and Simulations Random Numbers Function that returns a fractional number between 0 and 1 Function can be added by altering the more editing tag minimum: specifies a minimum value for the random number maximum: specifies a minimum value for the random number integerOnly: if the value is true, the function returns only whole numbers 6-15 6.4

16 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Tips for Games and Simulations Random Numbers Function that returns a fractional number between 0 and 1 Function can be added by altering the more editing tag minimum: specifies a minimum value for the random number maximum: specifies a minimum value for the random number integerOnly: if the value is true, the function returns only whole numbers 6-16 6.4

17 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Tips for Games and Simulations Playing Audio Several classes include sounds Sounds appear in the class’s thumbnail in the gallery An object’s properties’ tab also allows for sound to be imported and played 6-17 6.4

18 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Task #4 Students will open the IslandRescue World from the books example worlds and see how the various events are used to design the game that is showcased.. Students also need to open the RandomBee world and note how random numbers are used within the world. -Students should write a one paragraph summary over each of the two worlds 1) IslandRescue and 2)RandomBee that showcases how events(IslandRescue) or the random number(RandomBee) feature impacted the simulation and how it functioned. 6-18

19 Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Task #5 Design the following skills programs) from pages 298-301 valued at 50 points each. Students will select 2 of the following programs: 1,2,3,4 The students will then complete following challenge programs that will be worth 100 points each. Students should select two of the following programs. 6,7,8,9 Total points for the skills programs will equal 300. 6-19


Download ppt "Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition."

Similar presentations


Ads by Google