List Search Alice.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
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.
Execution Control with If/Else and Boolean Functions
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.
3D Game Programming All in One By Kenneth C. Finney.
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.
Programming: Simple Control Structures Sec 46 Web Design.
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.
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.
Alice Final Project Web Design. Alice Final Project You have a choice of two scenarios: 1. A game of some sort. You must devise a score-keeping mechanism.
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
Programming: Simple Control Structures
Arrays and Array Visualization
Obj: Introduction to Alice
Recursion Alice.
While: Indefinite Loops
Let's Race! Typing on the Home Row
Alice Concepts.
Recursion Alice.
Introduction to Alice Alice is named in honor of
Parameters Alice.
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
Interactive Programming
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.
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.
Parameters Alice.
Functions Alice.
Programming: Simple Control Structures
Creating An Animation Program
Parameters and Event-Handler Methods
Functions Alice.
under the direction of Professor Susan Rodger
Functions Alice.
Variables and Inheritance A More Complex Example
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.

Overall design Is the game over? yes congratulate no pop random mole Mouse click event yes Did mouse click on a mole? Play sound Change score display 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