1 / 10

Interactive 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 happens next, and then what happens…and so on. In movie-style programs the sequence of actions is determined by the programmer

nowles
Download Presentation

Interactive Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interactive Programming Alice

  2. Control of flow • Control of flow -- how the sequence of actions in a program is controlled. • What action happens first, what happens next, and then what happens…and so on. • In movie-style programs the sequence of actions is determined by the programmer • Creating a storyboard design • Writing program methods to carry out the designed sequence

  3. 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 • some other source of input • In essence, control of flow is now “in the hands of the user!”

  4. Events • Each time the user provides some sort of input, we say an event is generated. • An event is “something that happens”

  5. Event Handling methods • 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 handling method. • When an event is linked to a method that performs an action, a behavior is created.

  6. Example • Build an air show flight simulator. In an air show, the pilot uses biplane controls to perform acrobatic stunts.

  7. 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?

  8. 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

  9. 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

  10. Assignment #1 • An evil ninja is trying out for a karate movie and he needs a little practice. Create a world with a ninja object in a dojo. • The ninja needs to practice the following: jump, duck, chop (right arm and left arm), and kick(right leg and left leg). • Create events and event handling methods that provide the user with controls to make the ninja jump, duck, jab and kick.

More Related