Chapter 5 Interactive Programming - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Chapter 5 Interactive Programming

Description:

Letter 'P' event method. Space Bar. was selected. Flight ... Don't get fancy ---yet! Storyboard. flyForward. Do together. Biplane move. forward 2 meters, ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 26
Provided by: mhcc
Category:

less

Transcript and Presenter's Notes

Title: Chapter 5 Interactive Programming


1
Chapter 5 Interactive Programming
  • Dr Wayne Machuca
  • MHCC

2
Objects Inheritance
  • Recall that when you instantiate an object, the
    new object inherits from the class
  • Design
  • Properties
  • Values
  • And Methods
  • Methods are things that the object does or can do

3
Events
  • Events are things that cause a method to run
  • Press a key
  • Hit Enter
  • Click a mouse button
  • These are external influences that have an effect
    on a program.
  • Can you think of any others?

4
Event Handling Method
  • What do you want to have happen when a particular
    event occurs?
  • Many software have event handling methods
  • Visual Basic .NET
  • Java
  • HTML ltformgt
  • And more

5
Think like this
What EVENToccurred?
Space Bar was selected
Execute
Click event method
Space Barevent method
Letter Pevent method
Enter event method
6
Flight Simulator
7
Flight Simulator
  • Create a simple grass world
  • Add a biplane and some buildings
  • Dont get fancy---yet!

8
StoryboardflyForward
  • Do together
  • Biplane move forward 2 meters,duration 2.4
    sec,style abruptly
  • Play biplane engine sound

9
Story Boardbarrel
  • Event Spacebar press
  • Response
  • Do Together
  • Roll biplane full revolution
  • Play biplane engine sound

10
Now link the events to methods
  • When the world starts is an event
  • Alice creates this link automatically

11
We will create 2 new events
  • When the Up Arrow is selected, flyForward
  • When the Spacebar is selected, barrel

12
Create new event
2. Select
1. Select
13
(No Transcript)
14
Now add the barrel event
15
Listening
  • Events are world-level
  • Alice listens for an event to happenand the
    causes an action (method)appropriate to the
    event
  • Java (for example) also uses an event listener
    when then directs the action

16
Firetruck
17
Firetruck program
  • In this program you will create a grass world
  • Add burningBuilding
  • Add firetruck
  • Add 2 girls and 1 random guy
  • Place the people in the different windows

18
It should look something like this
People
19
Storyboard
  • EventClick on a person
  • ParameterswhichFloor, whichPerson, howFar
  • Methodpoint ladder at whichFloorextend ladder
    howFarwhichPerson slides down the ladderladder
    contracts howFar

20
Now create a new methodwith variables
21
Now create the method savePerson
This is a composite image
22
Now Create the Events
This is a composite image
23
Now lets try something a little harder
  • Greek Tragedy

24
Storyline
  • The scene is a Grecian stage
  • Zeus (a god) stands on a cloud above the stage.
    Various characters stand on the stage.
  • When a character is selected
  • Zeus turns to face that character
  • Zaps them with a lightening bolt
  • Special effects

25
Event
  • Eventobject is mouse clicked
  • Event handlershootBolt
  • Parameterwho (the object that was clicked)
  • ActionDo in order
  • Call prepareToShoot, who is target
  • Call lighteningAndThunder
  • Lightening move to clouds position.
Write a Comment
User Comments (0)
About PowerShow.com