1 / 19

Chapter 7: Events

Starting Out with Alice: A Visual Introduction to Programming Third Edition by Tony Gaddis. Chapter 7: Events. 6.1. Responding to Events. Event Action that take place while a world is playing Alice worlds detect events and respond to them For example:

ahumphrey
Download Presentation

Chapter 7: Events

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Starting Out with Alice: A Visual Introduction to Programming Third Edition by Tony Gaddis Chapter 7:Events

  2. 6.1 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!

  3. 6.1 Alice Events Process of responding to an event is called handling the event Tile for an event MUST appear in the Events Editor When worldis first created, the event when the world starts appears in the Events Editor

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

  5. 6.1 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 <object> Let the arrow keys move <subject> let the mouse move the camera Let the mouse orient the camera

  6. 6.1 Specialized Events • Some events from the previous list do not appear in the Events Editor • General event mustfirst be created • Right-click andselect change to • Changes an eventto a specializedevent

  7. 6.2 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 mustbe specified • any key is the placeholder until the“real” key is selected

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

  9. 6.2 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)

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

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

  12. Task #2 Students will explore mouse click events on pages283-284 by completing Tutorial 7-3 called Handling a mouse click event.

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

  14. Task #3 Open Up Globe in the books example programs and see the While the mouse is pressed on something event.

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

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

  17. 6.4 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 importedand played

  18. 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 or the random number feature impacted the simulation and how it functioned.

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

More Related