Events Chapter 7. Interactive Real world is interactive User determines order of actions instead of programmer.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Strings Strings are sequences of characters and / or digits “Alice” “ ” “I would like 3 peaches” When a model says or thinks, it is using a.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Class-level Methods Chapter 6. Class-level Method Is specific to a class of objects We can give a class new abilities/methods Only involves this one class.
Decision Structures Chapter 4. Chapter 4 Objectives To understand: o What values can be stored in a Boolean variable o What sequence structures are and.
PIIT Computer Science Summer Camp - Alice July 11, 2012 Brenda Parker Computer Science Department MTSU.
Events Chapter 7. Interactivity The real world is interactive User determines order of actions instead of programmer.
Parameters and Event-Handler Methods Alice. Mouse input Interactive programs often allow the user to use a mouse to click buttons in a windows-based interface.
Repetition Structures
Functions and Visual Effects Chapter 6 Part 3. Built-in Functions We have been using built-in functions so far 2.
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.
CS320n –Visual Programming Interactive Programs Mike Scott (Slides 5-1)
Programming in Alice Chapter 2 Part 2. Events Editor Identifies what method is executed (run) when the “Play” button is hit 2.
Interaction: Events and Event Handling
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
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.
Branching and Looping Examples, cont’d. Remember the generic triple jump world…
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
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.
Class-level Methods Chapter 6 part 1. Classes and Objects Classes o In Alice, classes are predefined as 3D models Objects o An object is an instance of.
Interaction: Events and Event Handling
Review For Test Chapter 4 & 5 Test is Wednesday, January 27th.
Decision Structures Chapter 4 Part 2. Chapter 4 Objectives To understand o What relational operators are and how they are used o Boolean logic o Testing.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Summer Computing Workshop. Session 2 Input in Scratch  Multi-Character input - This is used when the user is prompted to enter a number or word.  Problems.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Events Chapter 7 Part 2. While a Key is Pressed Event Specialized event An event occurs when you press a key and continues until you take your finger.
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.
Four Fundamental Pieces Instruction Control Structure Function Expression.
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,
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
Programming: Putting Together the Pieces Built-in Questions and Expressions Alice.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
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.
Programming: Putting Together the Pieces Built-in Functions and Expressions 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.
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 5 Sec 1 and 2 Oct 14, 2010 Prof. Susan Rodger.
Presenter: Carol Liss Timberlane Regional Middle School 6 th and 7 th grade Tech. Educator Co presenters:
Lesson Seven: Using Flags. What Are Flags? Flags are Variables or Switches Used to Help With Logic Control of your character. Normally, Flags are used.
Introducing Scratch Learning resources for the implementation of the scenario
Creating a UFO Rescue Game in Alice
Collision Theory and Logic
Programming & Scratch.
Starting Out with Alice: A Visual Introduction to Programming
Collision Theory and Logic
Introduction to Events
Creating a UFO Rescue Game in Alice
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Interactive Programming
Interactive Programming
Restricting Events Creating Conditional Events in Alice By Henry Qin
Variables and Inheritance A More Complex Example
Presentation transcript:

Events Chapter 7

Interactive Real world is interactive User determines order of actions instead of programmer

Control of Flow How sequence of actions in program is controlled o What action happens first, next, and so on Animations o Movie-style - programmer determines sequence of actions prior program running o Interactive - sequence of actions determined at runtime by user

Event Program reacts to o Mouse click o Key press on keyboard o Changes that occur during program execution Control of flow is now controlled by user

Events Each time user provides some sort of input, we say an event is generated o An event is “something that happens” An event may o Trigger a response o Move objects into positions that create a condition that triggers a response  Ex: A collision that moves objects

Event Handler Method Called when event occurs o Called behavior Linked to event in Event editor Behavior – when method linked to event is performed due to an action

Creating An Event Click on create new event in Events window

Alice Events When the world starts When a key is typed When the mouse is clicked on something While something is true When a variable changes Let the mouse move Let the arrow keys move let the mouse move the camera Let the mouse orient the camera See Table 7-1 on page 272 for details of each

Specialized Events Some events from the previous list do not appear in the Events Editor o While a key is pressed o While the mouse is pressed on something o While the world is running o When something becomes true To create specialized event o Create general event o Right-click and select change to

Key Press Event Alice can detect when a key on keyboard is pressed o Event is triggered when the user types a key o Key that will trigger the event must be specified o any key is the placeholder until you choose a specific key  Can have event activated when any key is pressed o Click on Nothing  Choose custom method from drop down menu

Tutorial 7-1: Key Press Event Have each fairy flap her wings and move up and down when a key is pressed called fly o When G is pressed event to cause Gossamer to fly o When M is pressed event to cause Hazelnut to fly 6-11

Storyboards 6-12 Event: G key is pressed Response: Do together Flap wings of Gossamer Move Gossamer up ½ meter Do together Flap wings of Gossamer Move Gossamer down ½ meter Event: M key is pressed Response: Do together Flap wings of Hazelnut Move Hazelnut up ½ meter Do together Flap wings of Hazelnut Move Hazelnut down ½ meter

Programs for Faeries Flying Both events can run at same time

Mouse Event Interactive programs often allow the user to use a mouse to click Examples o Buttons in a windows-based interface o Choose targets in a game o Select items in checklist on a form 6-14

Creating Mouse Event Event is triggered when the mouse is clicked on an object in the world Click on create new event and choose When the mouse is clicked on something It can be o Anything o Any object in the Alice World Choose event handler by clicking on nothing

Tutorial 7-3: Mouse Event Click on refrigerator door causes door to open o Can place Alice statement directly in event declaration 6-16

Fridge Door Opens and Closes To get door to open and close you need to remember the state of the door o Is it open or closed? o Use boolean variable: doorOpen If doorOpen = true then door is open o Close door o Set doorOpen to false If doorOpen = false then door is closed o Open door o Set doorOpen to true 6-17

Storyboard 6-18 Event: Mouse clicked on fridge door Response: If doorOpen = true Turn door right ¼ revolution doorOpen = false Else Turn door left ¼ revolution doorOpen = true

Program to Open and Close Door

Create Your Own People Models Use hebuilder and shebuilder o In People gallery o Choose all features of person o Has built-in methods  hello, angry, happy, walk, confused, no, yes

Homework Read chapter 6 sections 1 and 2 Answer questions in handout Do lab assignments after handing in answered questions Due one week after assigned with 1 week grace