SlideShare uma empresa Scribd logo
1 de 36
Event-driven programming
Most modern computer
programs that people
use have Graphical
User Interfaces (GUIs).
A GUI has icons on the
computer screen and a
mouse (or other device)
to control a pointer that
can be used to operate
the computer.
Event-Driven Programming
Event-Driven Programming
An Introduction to Programming Using Alice
Most modern computer
programs that people
use have Graphical
User Interfaces (GUIs).
A GUI has icons on the
computer screen and a
mouse (or other device)
to control a pointer that
can be used to operate
the computer.
This slide is an image of Microsoft Word
2007. It is an example of a modern
graphical user interface.
Modern GUIs like the Word 2007 interface require
the use of 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 occurs whenever an event listener
detects an event trigger and responds by running
a method called an event handler.
An event occurs whenever an event listener
detects an event trigger and responds by running
a method called an event handler.
Modern operating systems and programming
languages contain facilities to let programmers set
up event listeners.
An event trigger can be almost any activity or
condition selected by the programmer, such as a
mouse movement, someone pressing the enter
key, or a bank account balance changing.
An event handler is a method that is activated
when the event trigger occurs.
Almost any method can serve as an event handler,
such as those that play sounds, initiate data
communications, or perform calculations.
In Alice…
• Events can be used to control objects
moving in 3D space.
– Detect when some object moves
– Detect when two objects collide
– Make objects move in response to mouse or
keyboard commands.
• So before discussing events in Alice, let’s
talk about 3D space a little more.
3D space
• A dimension is a way of measuring
something.
• We create a dimension whenever we
assign a value on a continuous scale to
some property.
• Example: On a scale of 1 to 100, how
much do you approve of George Bush’s
performance as president?
Measuring distance
• If you wish to measure the location of a point on
a straight line, then you only need one number.
• You could mark a start point on the line, and
then measure how far a point is from the start
point
• By using negative and positive numbers, you
could also indicate which direction the distance
spans.
Orientation
• In addition, to the concepts of distance and
direction, we also have the concept of
orientation.
• Orientation means the direction the object is
facing.
• If an object is facing the positive direction on the
line, its orientation is forward.
• If facing negative, then backward.
Point of view
• Location and orientation together are
known as the point of view of an object.
Two ideas of direction
• Absolute vs. object-relative.
• Absolute direction of boy on bike I backward, but
forward in relation to Alice
Object-relative positions
• From the coach’s point of view, Alice is behind
the boy, while the coach is in front of the boy.
Position in 2D
• On a flat surface, like a sheet of paper, you need
two values to specify an object’s position (two
dimensions).
• Rene Descarte developed a system of
quantification for two dimensions.
• This is called Cartesian coordinates.
• Cartesian coordinates have an X axis
(dimension) and Y axis.
• The coordinates of a point are always specified
as x,y.
A third dimension
• Moving up and down off a flat plane
requires a third axis or dimension.
• Instead of an ordered pair to represent
position, we need an ordered triplet (x,y,z).
• In Alice the z axis provides a
measurement of depth.
• 3D space is sometimes called Euclidean
3-space after the Greek mathematician,
Euclid.
Absolute vs. Object-relative
• For all objects we must be aware of
absolute position and direction
• However, we are most commonly
concerned with object-relative position and
direction.
More on object-relativity
• We must also frequently consider the
movement of objects from the perspective
of other objects.
• See SharkAsSeenByExample.a2w
Events in Alice
Events in Alice
Alice events are created in the events area of the
standard Alice interface.
events area
Events in Alice
Alice events are created in the events area of the
standard Alice interface.
events area
Events in Alice
An Alice event tile specifies the event trigger
and the event handler.
In this example, the event trigger is the spacebar,
being pressed and the event handler is the
iceSkater’s simpleSpin method.
Events in Alice
create new event button
The create new event button will reveal a menu
with nine different event types.
Events in Alice
The create new event button will reveal a menu
with nine different event types.
Events in Alice
A programmer can pick the event type that has the
desired event trigger.
Events in Alice
Some event
types also have
built-in event
handlers…
A programmer can pick the event type that has the
desired event trigger.
Events in Alice
Some event
types also have
built-in event
handlers…
In other cases,
programmers
must specify
the handler.
A programmer can pick the event type that has the
desired event trigger.
Event handlers are specified by
dragging method tiles from the
details area and dropping them
into the event tile.
Exploring Events
• Start Alice and open the amusementPark
example world.
• In the events area, you should see seven
event tiles.
Amusement Park Events
Event-Driven Programming
• Events are an important part of Alice
programming, allowing the creation of interactive
worlds with keyboard and mouse user controls.
• Most modern programming languages allow
programmers to add events to new software.
• Events can be used for many other purposes,
such as controlling burglar alarms, checking
remote sensors, or checking for system events,
like printers running out of paper.
• Events are an important part of modern
computer programming.

Mais conteúdo relacionado

Semelhante a 03a-IntroductionToEventDrivenProgramming.ppt

event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptxusvirat1805
 
GRADE 5 TINKERCAD powepoint presentation
GRADE 5 TINKERCAD powepoint presentationGRADE 5 TINKERCAD powepoint presentation
GRADE 5 TINKERCAD powepoint presentationAllanGuevarra1
 
Unit 2 - Complete (1).pptx
Unit 2 - Complete (1).pptxUnit 2 - Complete (1).pptx
Unit 2 - Complete (1).pptxgogulram2
 
Application of Calculus in Computer Science.pptx
Application of Calculus in Computer Science.pptxApplication of Calculus in Computer Science.pptx
Application of Calculus in Computer Science.pptxMehedi Hasan
 
Programming-In-Alice.pptx
Programming-In-Alice.pptxProgramming-In-Alice.pptx
Programming-In-Alice.pptxCarlos134964
 
Digital illustration handbook
Digital illustration handbookDigital illustration handbook
Digital illustration handbookMrLawler
 
A SOFTWARE TOOL FOR EXPERIMENTAL STUDY LEAP MOTION
A SOFTWARE TOOL FOR EXPERIMENTAL STUDY LEAP MOTIONA SOFTWARE TOOL FOR EXPERIMENTAL STUDY LEAP MOTION
A SOFTWARE TOOL FOR EXPERIMENTAL STUDY LEAP MOTIONijcsit
 
Hands and Speech in Space: Multimodal Input for Augmented Reality
Hands and Speech in Space: Multimodal Input for Augmented Reality Hands and Speech in Space: Multimodal Input for Augmented Reality
Hands and Speech in Space: Multimodal Input for Augmented Reality Mark Billinghurst
 
Mar general pan hui ppt
Mar general pan hui ppt Mar general pan hui ppt
Mar general pan hui ppt luruiyang
 
Use Of Bearings And Its Impact On Society
Use Of Bearings And Its Impact On SocietyUse Of Bearings And Its Impact On Society
Use Of Bearings And Its Impact On SocietyJennifer Perry
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODSSanthiNivas
 
3.3 - The Math Object.pptx
3.3 - The Math Object.pptx3.3 - The Math Object.pptx
3.3 - The Math Object.pptxMaryhesterDeleon
 
Alice05
Alice05Alice05
Alice05h2vs10
 
Designing agents as if people mattered
Designing agents as if people matteredDesigning agents as if people mattered
Designing agents as if people matteredAryan Rathore
 
Popular search algorithms
Popular search algorithmsPopular search algorithms
Popular search algorithmsMinakshi Atre
 

Semelhante a 03a-IntroductionToEventDrivenProgramming.ppt (20)

Sixth sense technology
Sixth sense technologySixth sense technology
Sixth sense technology
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
GRADE 5 TINKERCAD powepoint presentation
GRADE 5 TINKERCAD powepoint presentationGRADE 5 TINKERCAD powepoint presentation
GRADE 5 TINKERCAD powepoint presentation
 
Unit 2 - Complete (1).pptx
Unit 2 - Complete (1).pptxUnit 2 - Complete (1).pptx
Unit 2 - Complete (1).pptx
 
Application of Calculus in Computer Science.pptx
Application of Calculus in Computer Science.pptxApplication of Calculus in Computer Science.pptx
Application of Calculus in Computer Science.pptx
 
Mobile Toolbox for Middle Years Maths
Mobile Toolbox for Middle Years MathsMobile Toolbox for Middle Years Maths
Mobile Toolbox for Middle Years Maths
 
Programming-In-Alice.pptx
Programming-In-Alice.pptxProgramming-In-Alice.pptx
Programming-In-Alice.pptx
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
Digital illustration handbook
Digital illustration handbookDigital illustration handbook
Digital illustration handbook
 
A SOFTWARE TOOL FOR EXPERIMENTAL STUDY LEAP MOTION
A SOFTWARE TOOL FOR EXPERIMENTAL STUDY LEAP MOTIONA SOFTWARE TOOL FOR EXPERIMENTAL STUDY LEAP MOTION
A SOFTWARE TOOL FOR EXPERIMENTAL STUDY LEAP MOTION
 
SIXTH SENSE TECHNOLOGY
SIXTH SENSE TECHNOLOGYSIXTH SENSE TECHNOLOGY
SIXTH SENSE TECHNOLOGY
 
Hands and Speech in Space: Multimodal Input for Augmented Reality
Hands and Speech in Space: Multimodal Input for Augmented Reality Hands and Speech in Space: Multimodal Input for Augmented Reality
Hands and Speech in Space: Multimodal Input for Augmented Reality
 
Mar general pan hui ppt
Mar general pan hui ppt Mar general pan hui ppt
Mar general pan hui ppt
 
Use Of Bearings And Its Impact On Society
Use Of Bearings And Its Impact On SocietyUse Of Bearings And Its Impact On Society
Use Of Bearings And Its Impact On Society
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODS
 
3.3 - The Math Object.pptx
3.3 - The Math Object.pptx3.3 - The Math Object.pptx
3.3 - The Math Object.pptx
 
01. Introduction.pptx
01. Introduction.pptx01. Introduction.pptx
01. Introduction.pptx
 
Alice05
Alice05Alice05
Alice05
 
Designing agents as if people mattered
Designing agents as if people matteredDesigning agents as if people mattered
Designing agents as if people mattered
 
Popular search algorithms
Popular search algorithmsPopular search algorithms
Popular search algorithms
 

Mais de tadudemise

What is requirement gathering chap3 1.pptx
What is requirement gathering chap3 1.pptxWhat is requirement gathering chap3 1.pptx
What is requirement gathering chap3 1.pptxtadudemise
 
chaptertaaaaaaaaaaaaaaadddddddd2222 4.ppt
chaptertaaaaaaaaaaaaaaadddddddd2222 4.pptchaptertaaaaaaaaaaaaaaadddddddd2222 4.ppt
chaptertaaaaaaaaaaaaaaadddddddd2222 4.ppttadudemise
 
03a-IntroductionToEventDrivenProgramming.ppt
03a-IntroductionToEventDrivenProgramming.ppt03a-IntroductionToEventDrivenProgramming.ppt
03a-IntroductionToEventDrivenProgramming.ppttadudemise
 
Introduction.ppt
Introduction.pptIntroduction.ppt
Introduction.ppttadudemise
 
SPL_PS2 (1).ppt
SPL_PS2 (1).pptSPL_PS2 (1).ppt
SPL_PS2 (1).ppttadudemise
 
cse581_03_EventProgramming.ppt
cse581_03_EventProgramming.pptcse581_03_EventProgramming.ppt
cse581_03_EventProgramming.ppttadudemise
 

Mais de tadudemise (8)

What is requirement gathering chap3 1.pptx
What is requirement gathering chap3 1.pptxWhat is requirement gathering chap3 1.pptx
What is requirement gathering chap3 1.pptx
 
chaptertaaaaaaaaaaaaaaadddddddd2222 4.ppt
chaptertaaaaaaaaaaaaaaadddddddd2222 4.pptchaptertaaaaaaaaaaaaaaadddddddd2222 4.ppt
chaptertaaaaaaaaaaaaaaadddddddd2222 4.ppt
 
8329969.ppt
8329969.ppt8329969.ppt
8329969.ppt
 
03a-IntroductionToEventDrivenProgramming.ppt
03a-IntroductionToEventDrivenProgramming.ppt03a-IntroductionToEventDrivenProgramming.ppt
03a-IntroductionToEventDrivenProgramming.ppt
 
Introduction.ppt
Introduction.pptIntroduction.ppt
Introduction.ppt
 
Chapter 1.ppt
Chapter 1.pptChapter 1.ppt
Chapter 1.ppt
 
SPL_PS2 (1).ppt
SPL_PS2 (1).pptSPL_PS2 (1).ppt
SPL_PS2 (1).ppt
 
cse581_03_EventProgramming.ppt
cse581_03_EventProgramming.pptcse581_03_EventProgramming.ppt
cse581_03_EventProgramming.ppt
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

03a-IntroductionToEventDrivenProgramming.ppt

  • 2. Most modern computer programs that people use have Graphical User Interfaces (GUIs). A GUI has icons on the computer screen and a mouse (or other device) to control a pointer that can be used to operate the computer. Event-Driven Programming
  • 3. Event-Driven Programming An Introduction to Programming Using Alice Most modern computer programs that people use have Graphical User Interfaces (GUIs). A GUI has icons on the computer screen and a mouse (or other device) to control a pointer that can be used to operate the computer.
  • 4. This slide is an image of Microsoft Word 2007. It is an example of a modern graphical user interface.
  • 5. Modern GUIs like the Word 2007 interface require the use of event-driven programming. An event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler.
  • 6. An event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler.
  • 7. An event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler. Modern operating systems and programming languages contain facilities to let programmers set up event listeners.
  • 8. An event trigger can be almost any activity or condition selected by the programmer, such as a mouse movement, someone pressing the enter key, or a bank account balance changing.
  • 9. An event handler is a method that is activated when the event trigger occurs. Almost any method can serve as an event handler, such as those that play sounds, initiate data communications, or perform calculations.
  • 10. In Alice… • Events can be used to control objects moving in 3D space. – Detect when some object moves – Detect when two objects collide – Make objects move in response to mouse or keyboard commands. • So before discussing events in Alice, let’s talk about 3D space a little more.
  • 11. 3D space • A dimension is a way of measuring something. • We create a dimension whenever we assign a value on a continuous scale to some property. • Example: On a scale of 1 to 100, how much do you approve of George Bush’s performance as president?
  • 12. Measuring distance • If you wish to measure the location of a point on a straight line, then you only need one number. • You could mark a start point on the line, and then measure how far a point is from the start point • By using negative and positive numbers, you could also indicate which direction the distance spans.
  • 13. Orientation • In addition, to the concepts of distance and direction, we also have the concept of orientation. • Orientation means the direction the object is facing. • If an object is facing the positive direction on the line, its orientation is forward. • If facing negative, then backward.
  • 14. Point of view • Location and orientation together are known as the point of view of an object.
  • 15. Two ideas of direction • Absolute vs. object-relative. • Absolute direction of boy on bike I backward, but forward in relation to Alice
  • 16. Object-relative positions • From the coach’s point of view, Alice is behind the boy, while the coach is in front of the boy.
  • 17. Position in 2D • On a flat surface, like a sheet of paper, you need two values to specify an object’s position (two dimensions). • Rene Descarte developed a system of quantification for two dimensions. • This is called Cartesian coordinates. • Cartesian coordinates have an X axis (dimension) and Y axis. • The coordinates of a point are always specified as x,y.
  • 18.
  • 19. A third dimension • Moving up and down off a flat plane requires a third axis or dimension. • Instead of an ordered pair to represent position, we need an ordered triplet (x,y,z). • In Alice the z axis provides a measurement of depth. • 3D space is sometimes called Euclidean 3-space after the Greek mathematician, Euclid.
  • 20.
  • 21. Absolute vs. Object-relative • For all objects we must be aware of absolute position and direction • However, we are most commonly concerned with object-relative position and direction.
  • 22.
  • 23. More on object-relativity • We must also frequently consider the movement of objects from the perspective of other objects. • See SharkAsSeenByExample.a2w
  • 25. Events in Alice Alice events are created in the events area of the standard Alice interface. events area
  • 26. Events in Alice Alice events are created in the events area of the standard Alice interface. events area
  • 27. Events in Alice An Alice event tile specifies the event trigger and the event handler. In this example, the event trigger is the spacebar, being pressed and the event handler is the iceSkater’s simpleSpin method.
  • 28. Events in Alice create new event button The create new event button will reveal a menu with nine different event types.
  • 29. Events in Alice The create new event button will reveal a menu with nine different event types.
  • 30. Events in Alice A programmer can pick the event type that has the desired event trigger.
  • 31. Events in Alice Some event types also have built-in event handlers… A programmer can pick the event type that has the desired event trigger.
  • 32. Events in Alice Some event types also have built-in event handlers… In other cases, programmers must specify the handler. A programmer can pick the event type that has the desired event trigger.
  • 33. Event handlers are specified by dragging method tiles from the details area and dropping them into the event tile.
  • 34. Exploring Events • Start Alice and open the amusementPark example world. • In the events area, you should see seven event tiles.
  • 36. Event-Driven Programming • Events are an important part of Alice programming, allowing the creation of interactive worlds with keyboard and mouse user controls. • Most modern programming languages allow programmers to add events to new software. • Events can be used for many other purposes, such as controlling burglar alarms, checking remote sensors, or checking for system events, like printers running out of paper. • Events are an important part of modern computer programming.