List Search Alice. Common Uses of Lists Iterating through a list of several like items to accomplish the same task with each item. As in the previous.

Slides:



Advertisements
Similar presentations
Microsoft® Small Basic
Advertisements

Events Chapter 7. Interactive Real world is interactive User determines order of actions instead of programmer.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
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.
While: Indefinite Loops Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we.
Parameters and Event-Handler Methods Sec 50 Web Design.
This game is loosely based on the Whack-A- Mole arcade game.  Each game starts with 45 seconds of play.  Moles randomly pop out of holes on the landscape.
More About Recursion Alice. A second form of recursion A second form of recursion is used when the solution to a problem depends on the ability to break.
Fall 2007ACS-1805 Ron McFadyen1 Ch 9 Lists In some animations, several objects must perform the same actions Example: A marching band, where the band members.
Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Making a Timer in Alice.
Execution Control with If/Else and Boolean Functions
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Parameters and Event-Handler Methods Sec 50 Web Design.
Review For Test Chapter 4 & 5 Test is Wednesday, January 27th.
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.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
Parameters and Event-Handler Methods Alice. Mouse clicks Interactive programs often allow the user to mouse click an object in the display. buttons in.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
3D Game Programming All in One By Kenneth C. Finney.
CS320n – Elements of Visual Programming Sending Parameters to Event Handler Methods (Slides 5-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
Programming: Simple Control Structures
List Search Alice. Common Uses of Lists Iterating through a list of several like items to accomplish the same task with each item. As in the previous.
Questions Alice. Functionality A question receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
By Mr. Putnam. In Catfall, the goal of the game is to touch the falling cats with the mouse. Every time you touch a cat, your score goes up by one point.
Interactive Programming Alice. Control of flow Control of flow -- how the sequence of actions in a program is controlled. What action happens first, what.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Parameters Alice. A beetle band Our task is to create an animation for a bug band as an advertisement for their next concert.
Debugging Watch and Text Output Alice. Debugging Techniques Several techniques are helpful in eliminating errors (bugs) in programs: careful design incremental.
Presenter: Carol Liss Timberlane Regional Middle School 6 th and 7 th grade Tech. Educator Co presenters:
1 Quiz Show Programming Terms. 2 Alice - 3D Virtual Programming Vocabulary Quiz Board Chapter 1 Chapter 2a Chapter 2b Chapter 3 Chapter 4 $100 $200 $300.
CS320n – Elements of Visual Programming List Search Mike Scott (Slides 9-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Parameters and Event-Handler Methods
Obj: Introduction to Alice
While: Indefinite Loops
Alice Concepts.
Introduction to Alice Alice is named in honor of
Classes, Objects, and World-level Methods
Programming: Simple Control Structures
Lists Alice.
Parameters and Event-Handler Methods
Lists Alice.
List Search Alice.
Introduction to Alice Alice is named in honor of
Programming: Simple Control Structures
Introduction to Alice Alice is named in honor of
Programming: Simple Control Structures
Programming: Simple Control Structures
Lists Alice.
Parameters and Event-Handler Methods
Functions Alice.
Parameters and Event-Handler Methods
Lists Alice.
Alice Concepts.
Introduction to Alice Alice is named in honor of
Programming: Simple Control Structures
More About Recursion Alice.
List Search Alice.
Ch 9 Lists In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing the same.
Functions Alice.
Programming: Simple Control Structures
Parameters and Event-Handler Methods
Functions Alice.
Functions Alice.
Presentation transcript:

List Search Alice

Common Uses of Lists Iterating through a list of several like items to accomplish the same task with each item. As in the previous Rockettes example Iterating through a list of several like items to search for one item that has a given property. This session demonstrates a list search.

Example A WacAMole arcade game. Little moles pop up from holes in the top of the booth. The user tries to whack the mole before it drops out of sight. The game is over when 10 moles are whacked.

Designing the game To design the game animation, we need to answer several questions: How will the game work, overall? How do we keep score? How do we know when the user whacks a mole? How will a list help us?

How will the game work, overall? A mole pops up and then goes back down. Each time the mole pops up, the user attempts to use the mouse to click the mole. When a click occurs, we check to see if a mole was clicked. If so, a sound plays and the score increases. The above actions repeat until the game is over.

Is the game over? Overall design pop random mole no yes congratulate Did mouse click on a mole? yes Play sound Change score display Mouse click event no do nothing

Storyboard for overall game This is the main driver for the game. The code will be written in World.my first method While the game isn't over randomly select one mole and call popMole Congratulate the user

Storyboard: popMole popMole Do in order Move the mole up Wait some time Move the mole back down

How do we keep score? We will use a visual scorekeeper. The scorekeeper is made up of two cylinders A gray cylinder above the ground A yellow cylinder below the ground. Each cylinder is 1 meter in height.

How do we keep score? Each time the user successfully clicks a mole, the yellow cylinder will move up 1/10 meter. When the yellow cylinder is above ground (has moved up 10 times), the game is over.

How do we know when the user has clicked on a mole? This is where a list comes in handy: create a list of the moles (one mole is below each hole) create a mouse click event each time the mouse is clicked, call a score method to iterate through the list of moles to see whether one of the moles has been clicked!

Storyboard: keep score Event: User clicks mouse Response: score For All in order If any mole in the mole list was the object clicked Make a noise Move the playerscore (yellow cylinder) up 1/10 meter

Demo Ch09Lec2WacAMole Concepts illustrated in this example A item can be randomly selected from a list In this example, a random mole was popped up from a list of moles. A visual scorekeeper gives the player feedback on the progress of a game.

Assignment Read Chapter 9 Section 2, List Search Read Tips & Techniques 9, Poses

Lab Chapter 9 Lecture 2 Lab