Introduction to Event Driven Programming
What are some ways that you as a user interact with programs?
Each one of these is an event.
Events, Event Listeners and Event Handlers
Add the following Section 2-10 Vocabulary to your Java Definitions document:
- Symbols used to express a relationship between two expressions.
- To give a variable a name and to define the type of data the variable will contain.
-
A place in memory where data of a specific type can be stored for later retrieval and use by your program.
-
To assign a variable a value.
-
Variables that store information about the object, such as color, width, height, and depth.
Begin Section 2: Lesson 10 - Variables slides.
Begin Section 2-10 Variables practice. Save the White Rabbit Project as 2-10 Random Hop. Save optional 1 activity as 2-10 Bunny Jazzercise.
Check with your instructor for special instructions before you begin Section 2-10 Variables project.
Steps for Section 2-10 Project.
Steps 1-8 - Random Head Shake
Steps 9-16 - Distance variable for the Swim procedure
Steps 17-25 - Adding a Parameter to the Swim procedure
Steps 26-28 - Using the Swim procedure for the Blue Tang fish
Steps 29-30 - Modifying Swim procedure and adding comments
Steps 30-47 - Refactoring your code by producing multiple procedures to reduce redundant code
Steps 30-36 - Creating the moveTail procedure
Steps 37-40 - Creating the moveFinsForward procedure
Steps 41-47 - Creating the moveFinsForward procedure
Steps 48-49 - Viewing the Java code
Steps 50-56 - Adding a loop
Steps 57-58 - Using your new procedures
Steps 59-61 - Adding Camera Movement
Steps 62-67 - Final modifications
Steps 68-70 - Adding Sound - stop after you add sound and demonstrate your program for teacher check.
Save the fish as Fish_10.
Note the following change to this section:
Step 44. This one is slightly different because it requires a parameter so make a dist parameter here exactly as you did before in step 18. Drag the parameter name over the red label to complete the procedure.
Add the following Section 2-11 Vocabulary to your Java Definitions document:
- Allow the user to control one or more objects with the keyboard keys while the animation is running.
-
Any action initiated by the user that is designed to influence the program’s execution during play.
-
Listen for, and react to, a keyboard keystroke that you specify.
-
The act of coding events to handle each procedure.
-
Procedures in the Scene class that listen for keyboard input while the animation is running.
Begin Section 2: Lesson 11 -Keyboard Controls slides.
Begin Section 2-11 Keyboard Controls practice. Save the White Rabbit Project as 2-11 Rabbit Keyboard. Save optional 1 activity as 2-11 Submarine. Save optional 2 activity as 2-11 Snow Yak.
Begin Section 2-11Keyboard Controls project. Save the fish as Fish_11.