CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

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.
Lights Camera Action! Part 3: BDE Events By Deborah Nelson under the direction of Professor Susan Rodger Duke University July 2008.
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.
Interaction: Events and Event Handling
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
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 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.
Execution Control with If/Else and Boolean Functions
CS320n –Visual Programming Introduction to Alice Mike Scott (Slides 2)
CSC1401: Introductory Programming Steve Cooper
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.
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.
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.
C H A P T E R T E N Event-Driven Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
Interactive Programming Sec 49 Web Design. Objectives The student will: Understand the difference between movie mode and an interactive program Understand.
Introduction to Programming G50PRO University of Nottingham Unit 2 : Introduction To Scratch Paul Tennent
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.
Review for test! Alice Chapter 1&2 Test is tomorrow! - March 26 th March 25th.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 2 Creating Your First Animation (An Introduction to Programming)
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.
Today we are learning to: Understand how flow charts are used to design games Add events to our objects to control stuff in our game – (Using the user.
CS320n –Visual Programming Definite / Counted Loops (Slides 7-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
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.
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.
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.
Introducing Scratch Learning resources for the implementation of the scenario
CS320n – Elements of Visual Programming
Starting Out with Alice: A Visual Introduction to Programming
Event-driven programming
Obj: Introduction to Alice
Introduction to Alice Alice is named in honor of
Introduction to Events
Event Driven Programming
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Introduction to Alice Alice is named in honor of
HAPPY NEW YEAR! Lesson 7: If-statements unplugged
Interactive Programming
Introduction to Alice Alice is named in honor of
Introduction to Alice Alice is named in honor of
ICT Programming Lesson 5:
Event-driven programming
Interactive Programming
Presentation transcript:

CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)

Visual ProgrammingInteractive Programs2 What We Will Do Today Learn about interactive programs Learn how to add events to Alice programs to make them interactive

Visual ProgrammingInteractive Programs3 Control of flow Control of flow – how the sequence of actions in a program is controlled –what actions happen first, second, third In movie style programs as shown in chapters 1-4 the sequence of actions is determined by the programmer –create a story board design –implement the program methods to carry out the designed sequence –completely predictable

Visual ProgrammingInteractive Programs4 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 –depending on your computer system

Visual ProgrammingInteractive Programs5 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 from previous executions of the program. In essence, control of flow is now “in the hands of the user.”

Visual ProgrammingInteractive Programs6 Events Each time the user provides some sort of input, we say an event is generated. – An event is “something that happens” –Magically the operating system passes information about the event to our program Interactive Program from appendix What happens when space pressed and method is not done?

Visual ProgrammingInteractive Programs7 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. We call this kind of method an event handler. When an event is linked to an event handler, a behavior is created.

Visual ProgrammingInteractive Programs8 How does this affect your program? We want to be able to write interactive programs –they can be more interesting than animations The approach will be the same as before, but the difference is that we must now be concerned with behaviors – input from the user -> (events) – how objects respond to an event -> (event handler methods)

Visual ProgrammingInteractive Programs9 Example Build an air show flight simulator. In an air show, the pilot uses biplane controls to perform acrobatic stunts.

Visual ProgrammingInteractive Programs10 Problem The whole idea in a flight simulator is to allow the user to control the flight path. The problem is: how do we write our program code to provide a guidance system that allows the user to be the pilot?

Visual ProgrammingInteractive Programs11 Solution Use keyboard input – Up-arrow key to move the biplane forward – Spacebar to make the biplane do a barrel turn (Note: other sets of keys could be used, we just arbitrarily picked a couple of keys on the keyboard.) Write event handler methods that respond to each key press

Visual ProgrammingInteractive Programs12 Storyboards Since two keys are used, two events are possible – so two storyboards are needed: Each storyboard outlines an event handler that responds to a particular event. Event: Spacebar press 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 engine sound

Visual ProgrammingInteractive Programs13 Demo A demonstration of building the biplane acrobatic simulation – flyForward – barrel

Visual ProgrammingInteractive Programs14 biplane.flyForward Coordinate duration of move and play sound instructions by matching the duration of the move to the duration of the sound

Visual ProgrammingInteractive Programs15 Events Editor - Linking Each event handler method must be linked to an event click “create new event” button in event window a template is created

Visual ProgrammingInteractive Programs16 Events Editor - Linking Select which key triggers the event Select which method in the program should be called when the event occurs

Visual ProgrammingInteractive Programs17 Testing Test event handler methods as they are developed. Write a method and test it, write a method and test it, and so on… (this is a technique called incremental development).

Visual ProgrammingInteractive Programs18 Adding More to Flight Simulator flyRight flyLeft loop alternate means of control