Interaction: Events and Event Handling

Slides:



Advertisements
Similar presentations
Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Advertisements

Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
PIIT Computer Science Summer Camp - Alice July 11, 2012 Brenda Parker Computer Science Department MTSU.
Alice Inheritance and Event Handling. Inheritance Concept Consider this hierarchy; parents describe properties of children Animals Vertebrates MammalsFish.
Events Chapter 7. Interactivity The real world is interactive User determines order of actions instead of programmer.
Events Chapter 7. Interactive Real world is interactive User determines order of actions instead of programmer.
Parameters and Event-Handler Methods Alice. Mouse input Interactive programs often allow the user to use a mouse to click buttons in a windows-based interface.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Parameters and Event-Handler Methods Sec 50 Web Design.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs.
Alice Variables Pepper. Set to Java look Edit / preferences restart.
Exploring Events. Try this Start Alice and create a blank world using the grass template. Add an instance of a BlueBallerina. Add an instance of a PinkBallerina.
CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)
Interaction: Events and Event Handling
Alice 2.0 Introduction to Event-Driven Programming Mr. Planck.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley This week: Whew!!! The last homework was tough! The homework for this week.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
Introduction to Scratch!
CompSci 4 Chap 5 Sec 1 Oct 13, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
Alice: Functions Alice Chapter 6 September 19, 2005.
Parameters and Event-Handler Methods Sec 50 Web Design.
Review For Test Chapter 4 & 5 Test is Wednesday, January 27th.
Event Driven Programming Chapter 5. Sequential Programming Computer-Centric Computer-Centric Program Runs as Programmer Intended Program Runs as Programmer.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Events (2) (Alice In Action, Ch 6) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
Today’s Agenda 1.Collect Pre-Lab 5 2.Collect Alice project storyboards 3.Events 4.Dummy Objects 5.Assign pair programming teams and meet upstairs for Lab.
Parameters and Event-Handler Methods Alice. Mouse clicks Interactive programs often allow the user to mouse click an object in the display. buttons in.
Parameters and Event-Handler Methods MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Interactive Programming Sec 49 Web Design. Objectives The student will: Understand the difference between movie mode and an interactive program Understand.
Variables and Inheritance A More Complex Example Alice.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Interactive Programming Alice. Control of flow Control of flow -- how the sequence of actions in a program is controlled. What action happens first, what.
Events (Alice In Action, Ch 6) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
CompSci 4 Chap 5 Sec 2 Oct 18, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
CS320n – Elements of Visual Programming Sending Parameters to Event Handler Methods (Slides 5-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
1 x 2 Game 1: One Player Game If you select a number sentence, give the answer. If you select an answer give the number sentence that has that answer.
List Search Alice. Common Uses of Lists Iterating through a list of several like items to accomplish the same task with each item. As in the previous.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Skater World: Part Three By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009.
Today we are learning to: Understand how actions and events control our game. Completing the catch the clown game – making a room – adding music Gather.
Interactive Programming Alice. Control of flow Control of flow -- how the sequence of actions in a program is controlled. What action happens first, what.
Chapter 5 Interaction: Events and Event Handling.
CompSci 4 Chap 5 Sec 2 Oct 9, 2008 Prof. Susan Rodger.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
Interactive Programming MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum redesign project.
Fall 2008ACS-1805 Ron McFadyen1 Event-driven programming Chapter 5 covers event-driven programming. Events are user or condition driven and so each event.
CompSci 4 Chap 5 Sec 1 and 2 Oct 14, 2010 Prof. Susan Rodger.
Lesson 8C Animation and Events. Step 3: Animation Drag it into the method and have him say “let her go!” Click on the knight in the object tree and scroll.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
Presenter: Carol Liss Timberlane Regional Middle School 6 th and 7 th grade Tech. Educator Co presenters:
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Starting Out with Alice: A Visual Introduction to Programming
Event-driven programming
Variables and Inheritance Part 2
Introduction to Events
Learn… Create… Program
Parameters and Event-Handler Methods
Learn… Create… Program
Interactive Programming
Parameters and Event-Handler Methods
Parameters and Event-Handler Methods
Learn… Create… Program
Learn… Create… Program
Event-driven programming
Parameters and Event-Handler Methods
Interactive Programming
Variables and Inheritance A More Complex Example
Presentation transcript:

Interaction: Events and Event Handling Chapter 5 - Alice Interaction: Events and Event Handling

Interactive Program –vs- Non-Interactive Program What is the main difference? The sequence of actions is determined at runtime! Occurs when: The user clicks the mouse Presses a key on the keyboard Objects in the scene move (randomly or guided by the user) User can create some conditions like a collision. Non-Interactive The sequence of actions is pre-determined by programmer Programmer designs a complete storyboard Programmer writes the program code for the animated actions. Every time the program runs the same sequence will occur.

What is an Event? An event is something that happens. Every time the user clicks the mouse or presses a key on the keyboard to send a signal to Alice about what to do next. The mouse click or key press is an event! In this chapter we learn the mechanics of how the user create an event and how the program responds to the event. Example: think of a video game – A Car Race. The scene is determined on how skillful the driver is steering the car.

Event handling method! How does it affect what I do? As a animation programmer you must think about all possible events and make plans for what should happen. You need to response to the events. Remember: When the event handling method occurs, the location of objects in the scene may or may not be the same as the last time.

Biplane Example: Is an interactive program! Biplane is in mid-air and the user is able to fly the plane. The plane can move forward, left, and right and a barrel turn. The user uses the keyboard and mouse to provide interaction. The whole idea is to let the user interact with the biplane.

Biplane Example: Has two events: The spacebar press for the barrel turn and the up arrow key to move the biplane forward. Event: Spacebar Response: Do together roll biplane a full revolution Play biplane engine sound Event: Up arrow key press Response: Do together move biplane forward play biplane egine sound Page 122 to 123. Just follow the steps.

Testing! How to test? Just save the world and press the PLAY button. Tip: It is important to test event handling methods as they are developed. Write a method and test it, write a method and test it, until the program is completed. Why? Incremental development! The advantage is in making it easier to debug your program. When something isn’t working, it can easily be fix before it causes bigger problems elsewhere in your program.

Parameters and event handling methods: Parameters are powerful! They allow us to customize methods to work with different objects and different numeric values. Take a look at the Firetruck/Burning Building example. (page 125 to 127, just follow the steps)

Burning Building Example: Another interactive program that shows how to use parameters in event handling methods. Firetruck is called to a burning building. The truck will need to extend its ladder so that each person can climb down to safety.

Burning Building Example: Three Events are: Event: Click on guy1 Responding Method: Save guy on the first floor Event: Click on girl2 Responding Method: Save girl on the second floor Event: Click on girl3 Responding Method: Save girl on the third floor Are all these events necessary? Why three? Can we do the same in one event?

Burning Building Example: A better solution is to write only one event and send the information to the action. Look: savePerson Parameters: whichFloor, whichPerson, howFar Do in order: Point ladder at whichFloor Extend the ladder howFar meters whichPerson slides down the ladder to the firetruck Pull the ladder back howFar meters Take a look at the program. Follow the steps on page 125 to 127

For Today: Read chapter 5! Take notes for yourself. (You can use them on the test) Complete the worksheet questions. You have 5 of them! Answers in Chapter 5. Finish with the examples in Chapter 5. Last chance if you want credit. Plane Program – Page 121 to 124 Burning Building – Page 125 to 127 Page 139, #12 Snow Festival.