CompSci 4 Chap 5 Sec 1 Oct 13, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.

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.
Events in Alice By Henry Qin, edited by Jenna Hayes under the direction of Professor Susan Rodger Duke University, August 2008.
Using “AsSeenBy” In Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
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.
CS320n –Visual Programming Random Numbers and Random Motion (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs.
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.
Fall 2009ACS-1805 Ron McFadyen1 ACS-1805 Introduction to Programming using Alice.
CS320n –Visual Programming Functions Mike Scott (Slides 6-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Problem Solving with Alice 2 & Friends.
Interaction: Events and Event Handling
Sequencing Miss Regan. Blood Hound  Does anyone know what the Bloodhound project is?  Video 1 Video 1  Video 2 Video 2  Link to website Link to website.
Event-driven programming. Most modern computer programs that people use have Graphical User Interfaces (GUIs). A GUI has icons on the computer screen.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
CSC1401: Introductory Programming Steve Cooper
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
Alice: Functions Alice Chapter 6 September 19, 2005.
Interaction: Events and Event Handling
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.
CompSci 4 Chap 7 Sec 2 Apr 7, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
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.
CompSci 4 Chap 8 Sec 1 Nov 17, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
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.
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.
Buttons and Birds: Introduction to Interactive Events in Alice By Henry Qin, edited by Jenna Hayes under the direction of Professor Susan Rodger Duke University,
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.
Unit 3 Music and Sound Evangel College S.2 ICT.
CompSci 4 Chap 4 Sec 1 Sept 15, 2005 Prof. Susan Rodger.
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.
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.
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.
CS320n –Visual Programming Definite / Counted Loops (Slides 7-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
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.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
CompSci 4 Chap 9 Sec 1 October 28, 2010 Prof. Susan Rodger.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Get Going On ….. Load the word file ‘Glossary’ and complete it. You will have homework today.
Stage 17 Play Lab: Create a Story
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.
CompSci 4 Chap 10 Nov 22, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
CS320n –Visual Programming Execution Control with If / Else and Boolean Functions (Slides 6-2-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
The Essentials of Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University May 2009.
Beginning Animation. Storyboard An Invitation to Dinner 1.Marlin and Dory (two small fish) are swimming and talking. 2.A shark (Bruce) swims up behind.
CS320n – Elements of Visual Programming List Search Mike Scott (Slides 9-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Event-driven programming
Introduction to Events
HAPPY NEW YEAR! Lesson 7: If-statements unplugged
Interactive Programming
Event-driven programming
Interactive Programming
Variables and Inheritance A More Complex Example
Presentation transcript:

CompSci 4 Chap 5 Sec 1 Oct 13, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas

Announcements Read Chapter 5 Sec 2 for next Tuesday New groups today Assignment 5 out

What we will do today Lecture on Chap 5, Sec 1 – Interactive Programming Classwork

Control of Flow Control of flow – how the sequence of actions in a program is controlled –What action happens first, second, third, …. In movie-style programs (Chaps 1-4) the sequence of actions is determined by the programmer –Creating a storyboard design –Writing program methods to carry out the designed sequence

Interactive Animations In interactive programs, the sequence of actions is determined at runtime, when the user provides input –Clicks the mouse –Presses a key on the keyboard Other sources of input are possible

Interactive Games In a video game where the user is guiding a spaceship, the sequence of actions … –Depends on what direction the user guides the ship –How fast the user presses the controls Each time the program runs, user input may cause a different sequence of actions Control of flow is “in the hands of the user”

Events Each time the user provides some sort of input, an event is generated –An event is something that happens From Appendix When spacebar pressed, Bee turns around

Event Handlers An event may –Trigger a response, or –Move objects into positions that create some condition (e.g. a collision) that triggers a response A method is called to carry out the response. The type of method is called an event handler. When an event is linked to an event handler, a behavior is created.

How does this effect your program? Our goal is to write interactive programs. The approach is the same as before, but the difference is now must be concerned with behaviors. – input from the user (events) –How objects respond to an event (event handler methods)

Example Build an air show flight simulator. The pilot uses the biplane controls to perform acrobatic stunts.

Problem The idea in a flight simulator –Allow user to control the flight path Problem –How do we write program code to provide a guidance system that allows the user to be the pilot?

Solution Use keyboard input –Up-arrow key to move the biplane forward –Spacebar to make the biplane do a barrel roll –Note: other keys could be chosen Write event handler methods that respond to each key press

Storyboards Since two keys are used, two events are possible – so two storyboards are needed Each storyboard outlines and event handler –Responds to a particular event Event: Spacebar press Response: Do together roll biplane a full revolution play biplane engine sound Event: Up arrow press Response: Do together move biplane forward play biplane engine sound

Demo A demo of building the biplane simulation –flyForward –barrel

biplane.flyForward Do not modify the length of the sound –use “as is” Coordinate duration of move and play sound –Match duration of move to duration of sound

Events Editor - Linking Each event handler method must be linked to an event 1) Select “create new event” Then choose the type of event 2) A template linking is created

Events Editor – Linking (cont) 3) Select type of key for event4) Select event handler method Final result:

Testing Test event handler methods as they are developed Write a method and test it, write a method and test it, and so on –incremental development

Classwork today Create 4 buttons and a spider robot Press green button and spider moves forward Press red button and spider moves backward Other two buttons?