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.

Slides:



Advertisements
Similar presentations
Microsoft® Small Basic
Advertisements

Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
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 2009ACS-1805 Ron McFadyen1 Functions A function is a collection of statement, similar to a method, but a function is defined to return a value to.
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 2007ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
Learn Alice Basic and Storyboard
Fall 2009ACS-1805 Ron McFadyen1 ACS-1805 Introduction to Programming using Alice.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
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.
Today’s Agenda 1.Collect Pre-Lab 4 2.Alice Programming Assignment Storyboards 3.Classes 4.Objects 5.Methods 6.Assign pair programming teams and meet upstairs.
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 Timer in Alice.
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.
Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Microsoft® Small Basic Collision Detection Estimated time to complete this lesson: 1 hour.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
CS320n – Elements of Visual Programming Lists Mike Scott (Slides 9-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
1 Quiz Template: Using the ‘ask user’ functions By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
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.
BDE tutorial By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 13, 2008.
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.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Programming in Alice IT-IDT-9 Design, develop, test and implement programs using visual programming. 9.1 Utilize drag and drop software to develop programs.
1 CSC 221: Computer Programming I Fall 2009 Introduction to programming in Scratch  animation sprites  motion, control & sensing  costume changes 
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.
Xin Liu Dec 1, Sound Open lab6.a2w Import horseneigh.wav as a property Add the method “play sound” to horse.neigh Exercise Create a class-level.
Creating a UFO Rescue Game in Alice
Lists and Iteration in Alice
Creating a UFO Rescue Game in Alice
Lists Alice.
Lists Alice.
List Search Alice.
Lists Alice.
Lists Alice.
Tutorial for Arrays and Lists
CSC 221: Introduction to Programming Fall 2018
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.
Event-driven programming
Presentation transcript:

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 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 2007ACS-1805 Ron McFadyen2 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 2007ACS-1805 Ron McFadyen3 Types of Lists In Alice, a list can be a list of numbers or a list of objects, colors, or other type ….

Fall 2007ACS-1805 Ron McFadyen4 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 2007ACS-1805 Ron McFadyen5 Creating the list Create the initial world and add five rockette objects to the world. Then, create a new world-level variable in the properties panel. (Why should it be world-level?)

Fall 2007ACS-1805 Ron McFadyen6 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 2007ACS-1805 Ron McFadyen7 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 2007ACS-1805 Ron McFadyen8 Iterating through a list Two control structures for iterating through a list: in order (one at a time) all together (simultaneously)

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

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

Fall 2007ACS-1805 Ron McFadyen11 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 2007ACS-1805 Ron McFadyen12 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 2007ACS-1805 Ron McFadyen13 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 2007ACS-1805 Ron McFadyen14 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 2007ACS-1805 Ron McFadyen15 Is the game over? Overall design pop random mole no yes congratulate Mouse click event See next slide

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

Fall 2007ACS-1805 Ron McFadyen17 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 2007ACS-1805 Ron McFadyen18 Storyboard: popMole popMole Do in order Move the mole up Wait some time Move the mole back down

Fall 2007ACS-1805 Ron McFadyen19 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 2007ACS-1805 Ron McFadyen20 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 2007ACS-1805 Ron McFadyen21 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 2007ACS-1805 Ron McFadyen22 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 …