Alice 2.0 - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Alice 2.0

Description:

Be honest and ethical, and ... Press Brake Pedal. Increase speed. Press Accelerator 'do' (handle) 'wait' (listen) 'Tell' (trigger) Using a Word Processor ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 13
Provided by: johnp58
Category:
Tags: alice

less

Transcript and Presenter's Notes

Title: Alice 2.0


1
Alice 2.0
  • Introduction to Event-Driven Programming
  • Mr. Planck

2
Show Respect
  • Value yourself. Be honest and ethical, and
    practice strong moral values.
  • Treat all members of the school community and all
    visitors with politeness and respect.
  • Honor the ideas and opinions of others.
  • Offer to help.
  • Be responsible with property and belongings.
  • FOLLOW THE LEADER!

3
  • The driver of a car is responsible for deciding
    what operations the car will perform. Without a
    driver the car will just wait for the driver to
    tell it what to do next. Looking at this picture
    what are some of the things a driver can tell a
    car to do?

4
Driving a Car
Tell (trigger) wait (listen) do (handle)
Press Accelerator Increase speed
Press Brake Pedal Decrease speed
Turn steering wheel right Turn front wheels right
Move stick shift to D Enable car to move forward
Move stick shift to R Enable car to move backward
Turn radio volume clockwise Increase radio volume
5
Using a Word Processor
  • What about a computer program like Microsoft
    Word?

Even Trigger (tell) Event Listener (wait) Event Handler (do)
Press B Type the letter b in the doc
Press the left mouse button Set the typing cursor in the doc
Alt F Open the File menu
  • The event trigger is typically caused by a
    computer user manipulating some hardware
    (keyboard, mouse, scanner, etc.) but can be
    anything (date/time, email address, etc.)

6
What is Event-driven programming?
  • In conventional programming, the sequence of
    operations for an application is determined by a
    central controlling program (e.g., a main
    procedure). In event-driven programming, the
    sequence of operations for an application is
    determined by the users interaction with the
    applications interface (forms, menus, buttons,
    etc.).
  • To create an event-driven application, the
    programmer creates small programscalled event
    handlersand associates them with specific events
    raised by specific objects.
  • Most, if not all, GUI systems are designed to be
    event driven, meaning that the main flow of your
    program is not sequential from beginning to end.
    If you've never done GUI programming, this is one
    of the trickiest paradigm shifts.
  • The Hollywood Principle "Don't call us we'll
    call you." ... You implement the event handlers,
    you get registered. You get called when the time
    is right (event trigger). This requires a
    distinctly different way of thinking to that
    which is taught in introductory programming where
    the student dictates the flow of control.

7
(No Transcript)
8
(No Transcript)
9
Event-driven programming
  • The use of a GUI on a computer system requires
    event-driven programming. An event occurs
    whenever an event listener detects an event
    trigger and responds by running a method called
    an event handler. An event listener is a
    combination of hardware and software that
    repeatedly checks the computer system for the
    event trigger.
  • An event trigger can be any activity or condition
    selected by the programmer, such as someone
    pressing the Enter key or a bank account balance
    going below zero.
  • An event handler is a method that is activated
    when the trigger occurs. Almost any method can
    serve as an event handler.

10
Extended Activity
  • Add three more events to your current ballerina
    world (keep the ones we created together, just
    add these additional ones)
  • Add an event trigger based on the up arrow key on
    the keyboard that will move the pinkBallerina up
    ½ meter
  • Add an event trigger based on the down arrow key
    on the keyboard that will move the pinkBallerina
    down ½ meter
  • Add and event trigger based on clicking the mouse
    on the pinkBallerina that will make her say
    Ouch!

11
Extended Activity
  • Once these new events are working properly print
    your work using the menu File-gtExport code for
    printing
  • A dialog box will appear, you must enter your
    name for the Authors name and the press the
    Export Code button (you will have many more
    directions to export than seen in the example
    below).

12
Extended Activity
  • Find the newly exported html file with your Alice
    code on the desktop and print it to hand in at
    the end of class.
  • Download Alice at http//www.alice.org/ to use on
    your home computer
Write a Comment
User Comments (0)
About PowerShow.com