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.

Slides:



Advertisements
Similar presentations
Microsoft® Small Basic
Advertisements

Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Introduction to Alice Alice is named in honor of
Fall 2007ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
Fall 2009ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
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.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs.
Fall 2007ACS-1805 Ron McFadyen1 Functions and if-else A function is a collection of statement, similar to a method, but a function is defined to return.
Fall 2008ACS-1805 Ron McFadyen1 Ch 8 Recursion Recursion occurs when a method (or function) calls itself.
Learn Alice Basic and Storyboard
Fall 2009ACS-1805 Ron McFadyen1 ACS-1805 Introduction to Programming using Alice.
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.
Princess & Dragon Part 4: Breathing Fire—Adding Effects to Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
1 Quiz Template: Click on the match By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
Tutorial for Arrays and Lists By Ruthie Tucker. Description This presentation will cover the basics of using Arrays and Lists in an Alice world This presentation.
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Alice Project 1 Web Design. Electronic Greeting Card Build an animation for an electronic greeting card (any occasion you choose – birthday, get well,
Interaction: Events and Event Handling
Review For Test Chapter 4 & 5 Test is Wednesday, January 27th.
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
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.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
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.
CS320n – Elements of Visual Programming Lists Mike Scott (Slides 9-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Fall 2009ACS-1805 Ron McFadyen1 Chapter 2 Program Design & Implementation.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
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.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 2 Creating Your First Animation (An Introduction to Programming)
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.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
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.
CompSci 4 Chap 9 Sec 1 October 28, 2010 Prof. Susan Rodger.
Presenter: Carol Liss Timberlane Regional Middle School 6 th and 7 th grade Tech. Educator Co presenters:
Introducing Scratch Learning resources for the implementation of the scenario
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.
Creating a UFO Rescue Game in Alice
By Melissa Dalis Professor Susan Rodger Duke University June 2011
Lists and Iteration in Alice
How to connect your brick
A Tutorial on How to Turn PowerPoint Presentations into Slideshows
Changing Color, Using Text Objects, and Random Selection in Alice
Let's Race! Typing on the Home Row
Creating a UFO Rescue Game in Alice
Graphics Movies & Games
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Memory Matching Challenge
Class-level Methods Alice.
Using Objects in Alice.
Lists Alice.
Lists Alice.
List Search Alice.
Making Objects Move in Unison: Using Lists
Lists Alice.
An Introduction to Programming Using Alice 2.2, Second Edition
Lists Alice.
How to submit preferences in TAMS as a Faculty member
Tutorial for Arrays and Lists
Classes.
Making Objects Move in Unison: Using Lists
CSC 221: Introduction to Programming Fall 2018
List Search Alice.
Event-driven programming
under the direction of Professor Susan Rodger
Presentation transcript:

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 marching steps. In such situations, it is convenient to collect all the objects into a list – a group or collection of objects Fall 2008 ACS-1805 Ron McFadyen

Lists With Alice, we can organize objects into a list. In our daily lives, we use lists to help us organize things. For example, to-do list assignments shopping In programming, a list is a special kind of data structure. Fall 2008 ACS-1805 Ron McFadyen

Types of Lists In Alice, a list can be a list of numbers or a list of objects, colors, or other type …. Fall 2008 ACS-1805 Ron McFadyen

Example The famous Rockettes® are preparing for their winter holiday show. You have been hired to create an animation for the holiday show that will be used on a web site where people can purchase tickets for the show. Fall 2008 ACS-1805 Ron McFadyen

Creating the list Create the initial world and add five rockette objects to the world. Create a new world-level variable in the properties panel. Fall 2008 ACS-1805 Ron McFadyen

Creating the list In the popup dialog box, type in a name select Object type check “make a List” box click new item button 5 times to select each of the 5 rockettes, one at a time Fall 2008 ACS-1805 Ron McFadyen

Programming with lists One of the most useful operations with a list is to repeatedly perform some action with each item in the list. This is called iteration or "iterating through a list." Fall 2008 ACS-1805 Ron McFadyen

Iterating through a list Two control structures for iterating through a list: in order (one at a time) all together (simultaneously) Fall 2008 ACS-1805 Ron McFadyen

Example: Iteration in Order A typical chorus line dance involves each dancer (one after the other) kicking up a leg. Possible storyboard: kickUpRightLeg Parameter: whichRockette Do in order Do together whichRockette right thigh turn back whichRockette right calf turn forward whichRockette right calf turn back For all dancers in order item_from_dancers kickUpRightLeg Implementing in Alice …. Fall 2008 ACS-1805 Ron McFadyen

Example: Iteration all together A typical chorus line dance involves each dancer (one after the other) kicking up a leg. Possible storyboard: kickUpRightLeg Parameter: whichRockette Do in order Do together whichRockette right thigh turn back whichRockette right calf turn forward whichRockette right calf turn back For all dancers simultaneously item_from_dancers kickUpRightLeg Implementing in Alice …. Fall 2008 ACS-1805 Ron McFadyen

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 an item with a given property... Fall 2008 ACS-1805 Ron McFadyen

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. Fall 2008 ACS-1805 Ron McFadyen

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? Fall 2008 ACS-1805 Ron McFadyen

How will the game work? 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. Fall 2008 ACS-1805 Ron McFadyen

Overall design See next slide Is the game over? yes congratulate no pop random mole Mouse click event See next slide Fall 2008 ACS-1805 Ron McFadyen

Overall design Mouse click event yes Did mouse click on a mole? Play sound Change score display no do nothing Fall 2008 ACS-1805 Ron McFadyen

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 Fall 2008 ACS-1805 Ron McFadyen

Storyboard: popMole popMole Do in order Move the mole up Wait some time Move the mole back down Fall 2008 ACS-1805 Ron McFadyen

Keeping 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. Fall 2008 ACS-1805 Ron McFadyen

Keeping 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. Fall 2008 ACS-1805 Ron McFadyen

When a mole is clicked 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! Fall 2008 ACS-1805 Ron McFadyen

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 And implementing in Alice … Fall 2008 ACS-1805 Ron McFadyen